forked from DebaucheryLibrarian/traxxx
670 lines
19 KiB
JavaScript
670 lines
19 KiB
JavaScript
/* eslint-disable max-len */
|
||
const upsert = require('../src/utils/upsert');
|
||
|
||
const grandParentNetworks = [
|
||
{
|
||
slug: 'gamma',
|
||
name: 'Gamma Entertainment',
|
||
url: 'https://www.gammaentertainment.com',
|
||
alias: ['gammaentertainment'],
|
||
},
|
||
{
|
||
slug: 'hush',
|
||
name: 'Hush',
|
||
},
|
||
{
|
||
slug: 'mindgeek',
|
||
name: 'Mind Geek',
|
||
url: 'https://www.mindgeek.com',
|
||
description: '',
|
||
parameters: {
|
||
interval: 1000,
|
||
concurrency: 1,
|
||
},
|
||
},
|
||
{
|
||
slug: 'whalemember',
|
||
name: 'Whale Member',
|
||
},
|
||
{
|
||
slug: 'paperstreetmedia',
|
||
name: 'Paper Street Media',
|
||
},
|
||
{
|
||
slug: 'porndoe',
|
||
name: 'PornDoe',
|
||
},
|
||
{
|
||
slug: 'wgcz',
|
||
name: 'WGCZ Holding',
|
||
},
|
||
];
|
||
|
||
const parentNetworks = [
|
||
{
|
||
slug: '21sextury',
|
||
name: '21Sextury',
|
||
url: 'https://www.21sextury.com',
|
||
description: 'Watch all the latest scenes and porn video updates on 21Sextury.com, the best European porn site with the hottest pornstars from all over the world! Watch porn videos from the large network here.',
|
||
parameters: {
|
||
layout: 'api',
|
||
mobile: 'https://m.dpfanatics.com/en/video',
|
||
},
|
||
parent: 'gamma',
|
||
},
|
||
];
|
||
|
||
const networks = [
|
||
{
|
||
slug: '21sextreme',
|
||
name: '21Sextreme',
|
||
url: 'https://www.21sextreme.com',
|
||
description: 'Welcome to 21Sextreme.com, your portal to fisting porn, old and young lesbians, horny grannies & extreme BDSM featuring the best Euro & American Pornstars',
|
||
parameters: {
|
||
layout: 'api',
|
||
mobile: 'https://m.dpfanatics.com/en/video',
|
||
},
|
||
parent: '21sextury',
|
||
},
|
||
{
|
||
slug: '21naturals',
|
||
name: '21Naturals',
|
||
url: 'https://www.21naturals.com',
|
||
description: 'Welcome to 21Naturals.com, the porn network featuring the hottest pornstars from all over the world in all natural porn and erotic sex videos. Watch thousands of girls with natural tits',
|
||
parameters: {
|
||
layout: 'api',
|
||
mobile: 'https://m.dpfanatics.com/en/video',
|
||
},
|
||
parent: '21sextury',
|
||
},
|
||
{
|
||
slug: 'adulttime',
|
||
name: 'Adult Time',
|
||
url: 'https://www.adulttime.com',
|
||
description: 'Adult Time is a premium streaming service for adults! Watch adult movies, series, and channels from the top names in the industry.',
|
||
parent: 'gamma',
|
||
},
|
||
{
|
||
slug: 'amateurallure',
|
||
name: 'Amateur Allure',
|
||
url: 'https://www.amateurallure.com',
|
||
},
|
||
{
|
||
slug: 'amateureuro',
|
||
name: 'Amateur Euro',
|
||
url: 'https://amateureuro.com',
|
||
parent: 'porndoe',
|
||
},
|
||
{
|
||
slug: 'assylum',
|
||
name: 'Assylum',
|
||
url: 'https://www.assylum.com',
|
||
description: 'At Assylum, submissive girls get dominated with rough anal sex, ass to mouth, hard BDSM, and sexual humiliation and degradation.',
|
||
},
|
||
{
|
||
slug: 'aziani',
|
||
name: 'Aziani',
|
||
url: 'https://www.aziani.com',
|
||
},
|
||
{
|
||
slug: 'babes',
|
||
name: 'Babes',
|
||
url: 'https://www.babes.com',
|
||
parent: 'mindgeek',
|
||
},
|
||
{
|
||
slug: 'badoink',
|
||
name: 'BaDoink',
|
||
url: 'http://www.badoink.com',
|
||
},
|
||
{
|
||
slug: 'bang',
|
||
name: 'Bang!',
|
||
url: 'https://bang.com',
|
||
},
|
||
{
|
||
slug: 'bangbros',
|
||
name: 'Bang Bros',
|
||
url: 'https://bangbros.com',
|
||
description: 'Here at Bang Bros, we only film the best highest quality porn with the sexiest Amateur girls and the top pornstars. Updated daily on Bangbros.com.',
|
||
parent: 'wgcz',
|
||
},
|
||
{
|
||
slug: 'blowpass',
|
||
name: 'Blowpass',
|
||
alias: ['myxxxpass'],
|
||
url: 'https://www.blowpass.com',
|
||
description: 'Welcome to Blowpass.com, your ultimate source for deepthroat porn, MILF and teen blowjob videos, big cumshots and any and everything oral!',
|
||
parameters: {
|
||
mobile: 'https://m.blowpass.com/en/video/v/%d', // v can be any string, %d will be scene ID
|
||
actorScenes: 'https://www.blowpass.com/en/videos/blowpass/latest/All-Categories/0{path}/{page}',
|
||
},
|
||
parent: 'gamma',
|
||
},
|
||
{
|
||
slug: 'brazzers',
|
||
name: 'Brazzers',
|
||
url: 'https://www.brazzers.com',
|
||
description: 'Brazzers homepage is updated daily with official HD porn scenes. Our hottest videos and sex series are filled with big tits, sexy milf, top pornstars and special events.',
|
||
parent: 'mindgeek',
|
||
parameters: {
|
||
childSession: true,
|
||
},
|
||
},
|
||
{
|
||
slug: 'boobpedia',
|
||
name: 'Boobpedia',
|
||
url: 'https://www.boobpedia.com',
|
||
type: 'info',
|
||
},
|
||
{
|
||
slug: 'cherrypimps',
|
||
name: 'Cherry Pimps',
|
||
url: 'https://www.cherrypimps.com',
|
||
description: 'CherryPimps your premium porn site to Download and Stream the hottest and most exclusive 4K HD videos and pictures on your phone, tablet, TV or console.',
|
||
},
|
||
{
|
||
slug: 'czechav',
|
||
name: 'CzechAV',
|
||
url: 'https://www.czechav.com',
|
||
},
|
||
{
|
||
slug: 'dorcel',
|
||
name: 'Marc Dorcel',
|
||
url: 'https://www.dorcel.com',
|
||
},
|
||
{
|
||
slug: 'evilangel',
|
||
name: 'Evil Angel',
|
||
url: 'https://www.evilangel.com',
|
||
description: 'Welcome to the award winning Evil Angel website, home to the most popular pornstars of today, yesterday and tomorrow in their most extreme and hardcore porn scenes to date. We feature almost 30 years of rough sex videos and hardcore anal porn like you\'ve never seen before, and have won countless AVN and XBiz awards including \'Best Site\' and \'Best Studio\'.',
|
||
parent: 'gamma',
|
||
parameters: {
|
||
layout: 'api',
|
||
},
|
||
},
|
||
{
|
||
slug: 'exploitedx',
|
||
name: 'ExpoitedX',
|
||
parameters: {
|
||
layout: 'tubular',
|
||
},
|
||
},
|
||
{
|
||
slug: 'freeones',
|
||
name: 'FreeOnes',
|
||
url: 'https://www.freeones.com',
|
||
type: 'info',
|
||
},
|
||
{
|
||
slug: 'pornworld',
|
||
name: 'Porn World',
|
||
alias: [
|
||
'ddf network',
|
||
'denys defrancesco',
|
||
],
|
||
url: 'https://pornworld.com',
|
||
description: 'European porn videos hub with exclusive VR, 4K and full HD XXX videos and hot sex photos of Europes finest porn star babes.',
|
||
parent: 'wgcz',
|
||
},
|
||
{
|
||
slug: 'digitalplayground',
|
||
name: 'Digital Playground',
|
||
url: 'https://www.digitalplayground.com',
|
||
description: 'DigitalPlayground.com is the leader in high quality adult blockbuster movies and award winning sex parodies that feature the most exclusive pornstars online! Adult Film Database of adult movies.',
|
||
parameters: {
|
||
actorPath: 'modelprofile',
|
||
},
|
||
parent: 'mindgeek',
|
||
},
|
||
{
|
||
slug: 'dogfartnetwork',
|
||
name: 'Dogfart Network',
|
||
url: 'https://dogfartnetwork.com',
|
||
description: 'The world famous Dogfart Interracial series. Online since 1996, we have the largest collection of Interracial videos, pictures and content on the web.',
|
||
},
|
||
{
|
||
slug: 'fantasymassage',
|
||
name: 'Fantasy Massage',
|
||
url: 'https://www.fantasymassage.com',
|
||
parameters: {
|
||
mobile: 'https://m.dpfanatics.com/en/video',
|
||
},
|
||
parent: 'gamma',
|
||
},
|
||
{
|
||
slug: 'famedigital',
|
||
name: 'Fame Digital',
|
||
url: 'https://www.famedigital.com',
|
||
description: 'Watch and download thousands of the best porn videos at FameDigital.com, the largest porn network on the web! The hottest teens, MILFs and more pornstars are all here!',
|
||
parameters: {
|
||
mobile: 'https://m.dpfanatics.com/en/video',
|
||
},
|
||
parent: 'gamma',
|
||
},
|
||
{
|
||
slug: 'fakehub',
|
||
name: 'Fake Hub',
|
||
url: 'https://www.fakehub.com',
|
||
description: 'Wherever they go, there is porn. Hospital, Taxis, Casting… Maybe fucking to a fake cop, fake agent or fake taxi driver. And we record it all.',
|
||
parameters: {
|
||
actorPath: 'modelprofile',
|
||
},
|
||
parent: 'mindgeek',
|
||
},
|
||
{
|
||
slug: 'firstanalquest',
|
||
name: 'First Anal Quest',
|
||
url: 'http://www.firstanalquest.com',
|
||
},
|
||
{
|
||
slug: 'forbondage',
|
||
name: 'ForBondage',
|
||
url: 'https://forbondage.com',
|
||
parent: 'porndoe',
|
||
},
|
||
{
|
||
slug: 'fullpornnetwork',
|
||
name: 'Full Porn Network',
|
||
url: 'https://www.fullpornnetwork.com',
|
||
description: 'FullPornNetwork.com is the latest and greatest for one stop shop porn sites. Check out the expanding library of the multi-site network. All of fan\'s favorite content from ANALIZED.COM, DTFsluts.com, YourMomDoesPorn.com and many more. Give die hard porn fans access to an array of premium content available in 4k and 1080p. Full access included streaming hd and unlimited downloads. Be exclusive, be a member to FullPornNetwork.com Today.',
|
||
},
|
||
{
|
||
slug: 'gaywire',
|
||
name: 'Gaywire',
|
||
url: 'https://www.gaywire.com',
|
||
tags: ['gay'],
|
||
},
|
||
{
|
||
slug: 'girlsway',
|
||
name: 'Girlsway',
|
||
url: 'https://www.girlsway.com',
|
||
description: 'Girlsway.com has the best lesbian porn videos online! The hottest pornstars & first time lesbians in real girl on girl sex, tribbing, squirting & pussy licking action right HERE!',
|
||
parameters: {
|
||
layout: 'api',
|
||
},
|
||
parent: 'gamma',
|
||
},
|
||
{
|
||
slug: 'hitzefrei',
|
||
name: 'Hitzefrei',
|
||
url: 'http://www.hitzefrei.com',
|
||
},
|
||
{
|
||
slug: 'hussiepass',
|
||
name: 'Hussie Pass',
|
||
url: 'https://www.hussiepass.com',
|
||
parent: 'hush',
|
||
},
|
||
{
|
||
slug: 'hushpass',
|
||
name: 'Hush Pass',
|
||
url: 'https://www.hushpass.com',
|
||
parent: 'hush',
|
||
parameters: {
|
||
t1: true,
|
||
sequential: true,
|
||
},
|
||
},
|
||
{
|
||
slug: 'interracialpass',
|
||
name: 'Interracial Pass',
|
||
url: 'https://www.interracialpass.com',
|
||
parent: 'hush',
|
||
parameters: {
|
||
t1: true,
|
||
sequential: true,
|
||
},
|
||
},
|
||
{
|
||
slug: 'insex',
|
||
name: 'Insex',
|
||
description: 'The original bondage and BDSM transgression.',
|
||
url: 'http://www.insex.com',
|
||
},
|
||
{
|
||
slug: 'jayrock',
|
||
name: 'JayRock Productions',
|
||
url: 'http://jayrockcontent.com',
|
||
parent: 'gamma',
|
||
},
|
||
{
|
||
slug: 'julesjordan',
|
||
name: 'Jules Jordan',
|
||
url: 'https://www.julesjordan.com',
|
||
},
|
||
{
|
||
slug: 'karups',
|
||
name: 'Karups',
|
||
url: 'https://www.karups.com',
|
||
},
|
||
{
|
||
slug: 'kellymadison',
|
||
name: 'Kelly Madison Media',
|
||
url: 'https://www.kellymadison.com',
|
||
description: 'Home of Kelly Madison and Ryan Madison',
|
||
},
|
||
{
|
||
slug: 'killergram',
|
||
name: 'Killergram',
|
||
url: 'http://www.killergram.com',
|
||
},
|
||
{
|
||
slug: 'kink',
|
||
name: 'Kink',
|
||
url: 'https://www.kink.com',
|
||
description: 'Authentic Bondage & Real BDSM Porn Videos. Demystifying and celebrating alternative sexuality by providing the most authentic kinky videos. Experience the other side of porn.',
|
||
},
|
||
{
|
||
slug: 'letsdoeit',
|
||
name: 'LetsDoeIt',
|
||
url: 'https://letsdoeit.com',
|
||
parent: 'porndoe',
|
||
},
|
||
{
|
||
slug: 'littlecapricedreams',
|
||
name: 'Little Caprice Dreams',
|
||
url: 'https://www.littlecaprice-dreams.com',
|
||
},
|
||
{
|
||
slug: 'mamacitaz',
|
||
name: 'Mamacitaz',
|
||
url: 'https://mamacitaz.com',
|
||
parent: 'porndoe',
|
||
},
|
||
{
|
||
slug: 'men',
|
||
name: 'Men',
|
||
url: 'https://www.men.com',
|
||
description: 'Check out the best gay porn site on the net with daily updates, award-winning original series, exclusive Men.com models and over 800 of the hottest guys in gay porn.',
|
||
parameters: {
|
||
actorPath: 'modelprofile',
|
||
},
|
||
parent: 'mindgeek',
|
||
},
|
||
{
|
||
slug: 'metrohd',
|
||
name: 'Metro HD',
|
||
url: 'https://www.metrohd.com',
|
||
description: 'Checkout MetroHD official pornsite featuring top rated pornstars and XXX videos.',
|
||
parent: 'mindgeek',
|
||
},
|
||
{
|
||
slug: 'mikeadriano',
|
||
name: 'Mike Adriano',
|
||
url: 'https://www.mikeadriano.com',
|
||
},
|
||
{
|
||
slug: 'milehighmedia',
|
||
name: 'Mile High Media',
|
||
url: 'https://www.milehighmedia.com',
|
||
description: 'MileHighMedia.com is the only niche porn network you need! Watch lesbian sex, hardcore fucking and family porn stories with the hottest teens & MILFs!',
|
||
parent: 'mindgeek',
|
||
},
|
||
{
|
||
slug: 'mofos',
|
||
name: 'MOFOS',
|
||
url: 'https://www.mofos.com',
|
||
description: 'Check out the Official Mofos Network of best amateur pornsites. Girlfriend – voyeur - college girls - first anal & more. Bonus Milf sites for wifey lovers.',
|
||
parent: 'mindgeek',
|
||
},
|
||
{
|
||
slug: 'mylf',
|
||
name: 'MYLF',
|
||
tags: ['milf'],
|
||
url: 'https://www.mylf.com',
|
||
parent: 'paperstreetmedia',
|
||
parameters: {
|
||
videos: 'https://store2.psmcdn.net/mylf-elastic-hka5k7vyuw-videoscontent/_doc',
|
||
profiles: 'https://store2.psmcdn.net/mylf-elastic-hka5k7vyuw-modelscontent/_doc/{slug}',
|
||
avatars: 'https://images.mylfcdn.net/tsv4/model/profiles',
|
||
},
|
||
},
|
||
{
|
||
slug: 'naughtyamerica',
|
||
name: 'Naughty America',
|
||
url: 'https://www.naughtyamerica.com',
|
||
description: 'The best porn movies daily at Naughty America! Experience the most seductive porn stars in stunning virtual reality, 4K and HD porn videos!',
|
||
},
|
||
{
|
||
slug: 'nebraskacoeds',
|
||
name: 'Nebraska Coeds',
|
||
url: 'https://nebraskacoeds.com',
|
||
parameters: {
|
||
layout: 'classic',
|
||
},
|
||
},
|
||
{
|
||
slug: 'newsensations',
|
||
name: 'New Sensations',
|
||
url: 'https://www.newsensations.com',
|
||
description: 'Home to multiple award-winning studios New Sensations & Digital Sin with over 7,000 HQ porn movies! Take the free tour now!',
|
||
},
|
||
{
|
||
slug: 'nubiles',
|
||
name: 'Nubiles',
|
||
url: 'https://www.nubiles.com',
|
||
description: 'Welcome to the teen megasite that started it all! Browse our massive HD collection of fresh legal hotties at Nubiles.net.',
|
||
},
|
||
{
|
||
slug: 'perfectgonzo',
|
||
name: 'Perfect Gonzo',
|
||
url: 'https://www.perfectgonzo.com',
|
||
description: '',
|
||
},
|
||
{
|
||
slug: 'pervcity',
|
||
name: 'Perv City',
|
||
url: 'https://www.pervcity.com',
|
||
parameters: {
|
||
networkEntryIds: true,
|
||
},
|
||
},
|
||
{
|
||
slug: 'pimpxxx',
|
||
name: 'Pimp.XXX',
|
||
url: 'https://www.pimp.xxx',
|
||
description: 'PIMP.XXX is the NEWEST and HOTTEST site featuring Exclusive Ultra High Definition 4k videos updated daily! Featuring the newest and the biggest pornstars with Big Tits, Tight Asses, and more!',
|
||
},
|
||
{
|
||
slug: 'porncz',
|
||
name: 'PornCZ',
|
||
url: 'https://www.porncz.com',
|
||
},
|
||
{
|
||
slug: 'pornpros',
|
||
name: 'Porn Pros',
|
||
url: 'https://pornpros.com',
|
||
description: 'Watch the best HD exclusive movies and videos on Porn Pros. All the hottest new Pornstar and amateur girls in High Definition updated daily.',
|
||
parent: 'whalemember',
|
||
},
|
||
{
|
||
slug: 'private',
|
||
name: 'Private',
|
||
url: 'https://www.private.com',
|
||
description: 'Private is the best source for adult movies and videos. Featuring the most popular hardcore adult stars in hundreds of porn movies, Private.com delivers...',
|
||
parent: 'wgcz',
|
||
},
|
||
{
|
||
slug: 'puretaboo',
|
||
name: 'Pure Taboo',
|
||
url: 'https://www.puretaboo.com',
|
||
description: 'PureTaboo.com is the ultimate site for family taboo porn, featuring submissive teens & virgins in rough sex videos in ultra 4k HD.',
|
||
parameters: {
|
||
layout: 'api',
|
||
},
|
||
parent: 'gamma',
|
||
},
|
||
{
|
||
slug: 'realitykings',
|
||
name: 'Reality Kings',
|
||
url: 'https://www.realitykings.com',
|
||
description: 'Home of HD reality porn featuring the nicest tits and ass online! The hottest curvy girls in real amateur sex stories are only on REALITYkings.com',
|
||
parent: 'mindgeek',
|
||
},
|
||
{
|
||
slug: 'score',
|
||
name: 'SCORE',
|
||
url: 'https://www.scorepass.com',
|
||
description: '',
|
||
},
|
||
{
|
||
slug: 'sexyhub',
|
||
name: 'Sexy Hub',
|
||
url: 'https://www.sexyhub.com',
|
||
parent: 'mindgeek',
|
||
},
|
||
{
|
||
slug: 'teamskeet',
|
||
name: 'Team Skeet',
|
||
url: 'https://www.teamskeet.com',
|
||
description: 'Welcome to teamskeet.com, the largest collection of exclusive teen porn sites and videos on the web. Check out our TeamSkeet porn sites now.',
|
||
parent: 'paperstreetmedia',
|
||
parameters: {
|
||
videos: 'https://store2.psmcdn.net/ts-elastic-d5cat0jl5o-videoscontent',
|
||
profiles: 'https://store.psmcdn.net/ts-organic-iiiokv9kyo/modelsContent/{slug}.json',
|
||
avatars: 'https://images.mylfcdn.net/tsv4/model/profiles',
|
||
},
|
||
},
|
||
{
|
||
slug: 'teencoreclub',
|
||
name: 'Teen Core Club',
|
||
url: 'https://teencoreclub.com',
|
||
},
|
||
{
|
||
slug: 'topwebmodels',
|
||
name: 'Top Web Models',
|
||
url: 'https://tour.topwebmodels.com',
|
||
parameters: {
|
||
apiKey: '5b637cd8c4bc59cd13686f1c38dcb780',
|
||
},
|
||
},
|
||
{
|
||
slug: 'transbella',
|
||
name: 'Trans Bella',
|
||
url: 'https://transbella.com',
|
||
tags: ['transsexual'],
|
||
parent: 'porndoe',
|
||
},
|
||
{
|
||
slug: 'traxxx',
|
||
name: 'traxxx',
|
||
url: 'https://traxxx.me',
|
||
},
|
||
{
|
||
slug: 'twistys',
|
||
name: 'Twistys',
|
||
url: 'https://www.twistys.com',
|
||
description: 'The hottest high quality glamour porn for over 18 years! Over 3700+ models and 46000+ scenes. TWISTYS.com',
|
||
parent: 'mindgeek',
|
||
},
|
||
{
|
||
slug: 'vipsexvault',
|
||
name: 'VIP Sex Vault',
|
||
url: 'https://vipsexvault.com',
|
||
parent: 'porndoe',
|
||
},
|
||
{
|
||
slug: 'vivid',
|
||
name: 'Vivid',
|
||
url: 'https://www.vivid.com',
|
||
description: 'Home of the Kim Kardashian Sex Tape, Porn Parodies, and over 30,000 XXX Movies from The World Leader In Adult Entertainment.',
|
||
parent: 'gamma',
|
||
},
|
||
{
|
||
slug: 'vixen',
|
||
name: 'Vixen',
|
||
url: 'https://www.vixen.com',
|
||
description: 'Vixen.com features the world’s finest cinematic adult films with 4K quality and high-end erotic photography.',
|
||
},
|
||
{
|
||
slug: 'wankzvr',
|
||
name: 'WankzVR',
|
||
url: 'https://www.wankzvr.com',
|
||
},
|
||
{
|
||
slug: 'pierrewoodman',
|
||
name: 'Pierre Woodman',
|
||
url: 'http://www.woodmancastingx.com',
|
||
},
|
||
{
|
||
slug: 'xempire',
|
||
name: 'XEmpire',
|
||
url: 'https://www.xempire.com',
|
||
description: 'XEmpire.com brings you today\'s top pornstars in beautifully shot, HD sex scenes across 4 unique porn sites of gonzo porn, interracial, lesbian & erotica!',
|
||
parameters: {
|
||
actorScenes: 'https://www.xempire.com/en/videos/xempire/latest/{page}/All-Categories/0{actorPath}',
|
||
},
|
||
parent: 'gamma',
|
||
},
|
||
{
|
||
slug: 'zerotolerance',
|
||
name: 'Zero Tolerance',
|
||
alias: ['ztod'],
|
||
url: 'http://www.ztod.com',
|
||
parameters: {
|
||
layout: 'api',
|
||
},
|
||
parent: 'gamma',
|
||
},
|
||
];
|
||
|
||
exports.seed = knex => Promise.resolve()
|
||
.then(async () => {
|
||
const grandParentNetworkEntries = await upsert('entities', grandParentNetworks.map(network => ({ ...network, type: 'network' })), ['slug', 'type'], knex);
|
||
const grandParentNetworksBySlug = [].concat(grandParentNetworkEntries.inserted, grandParentNetworkEntries.updated).reduce((acc, network) => ({ ...acc, [network.slug]: network.id }), {});
|
||
|
||
const parentNetworksWithGrandParent = parentNetworks.map(network => ({
|
||
slug: network.slug,
|
||
name: network.name,
|
||
type: network.type || 'network',
|
||
alias: network.alias,
|
||
url: network.url,
|
||
description: network.description,
|
||
parameters: network.parameters,
|
||
parent_id: grandParentNetworksBySlug[network.parent] || null,
|
||
}));
|
||
|
||
const parentNetworkEntries = await upsert('entities', parentNetworksWithGrandParent, ['slug', 'type'], knex);
|
||
const parentNetworksBySlug = [].concat(parentNetworkEntries.inserted, parentNetworkEntries.updated).reduce((acc, network) => ({ ...acc, [network.slug]: network.id }), {});
|
||
|
||
const networksWithParent = networks.map(network => ({
|
||
slug: network.slug,
|
||
name: network.name,
|
||
type: network.type || 'network',
|
||
alias: network.alias,
|
||
url: network.url,
|
||
description: network.description,
|
||
parameters: network.parameters,
|
||
parent_id: parentNetworksBySlug[network.parent] || grandParentNetworksBySlug[network.parent] || null,
|
||
}));
|
||
|
||
const networkEntries = await upsert('entities', networksWithParent, ['slug', 'type'], knex);
|
||
|
||
const networkIdsBySlug = [].concat(
|
||
grandParentNetworkEntries.inserted,
|
||
grandParentNetworkEntries.updated,
|
||
parentNetworkEntries.inserted,
|
||
parentNetworkEntries.updated,
|
||
networkEntries.inserted,
|
||
networkEntries.updated,
|
||
).reduce((acc, network) => ({ ...acc, [network.slug]: network.id }), {});
|
||
|
||
const tagSlugs = networks.map(network => network.tags).flat().filter(Boolean);
|
||
|
||
const tagEntries = await knex('tags').whereIn('slug', tagSlugs);
|
||
const tagIdsBySlug = tagEntries.reduce((acc, tag) => ({ ...acc, [tag.slug]: tag.id }), {});
|
||
|
||
const tagAssociations = networks
|
||
.map(network => (network.tags
|
||
? network.tags.map(tagSlug => ({
|
||
entity_id: networkIdsBySlug[network.slug],
|
||
tag_id: tagIdsBySlug[tagSlug],
|
||
inherit: true,
|
||
}))
|
||
: []))
|
||
.flat();
|
||
|
||
await upsert('entities_tags', tagAssociations, ['entity_id', 'tag_id'], knex);
|
||
});
|