const upsert = require('../src/utils/upsert'); const studios = [ // LegalPorno { slug: 'gonzocom', name: 'Gonzo.com', url: 'https://www.legalporno.com/studios/gonzo_com', parent: 'legalporno', }, { slug: 'giorgiograndi', name: 'Giorgio Grandi', url: 'https://www.legalporno.com/studios/giorgio-grandi', parent: 'legalporno', }, { slug: 'hardpornworld', name: 'Hard Porn World', url: 'https://www.legalporno.com/studios/hard-porn-world', parent: 'legalporno', }, { slug: 'interracialvision', name: 'Interracial Vision', url: 'https://www.legalporno.com/studios/interracial-vision', parent: 'legalporno', }, { slug: 'giorgioslab', name: 'Giorgio\'s Lab', url: 'https://www.legalporno.com/studios/giorgio--s-lab', parent: 'legalporno', }, { slug: 'americananal', name: 'American Anal', url: 'https://www.legalporno.com/studios/american-anal', parent: 'legalporno', }, { slug: 'assablanca', name: 'Assablanca', url: 'https://www.legalporno.com/studios/assablanca', parent: 'legalporno', }, { slug: 'focus', name: 'Focus', url: 'https://www.legalporno.com/studios/focus', parent: 'legalporno', }, { slug: 'analforever', name: 'Anal Forever', url: 'https://www.legalporno.com/studios/anal-forever', parent: 'legalporno', }, { slug: 'gonzoinbrazil', name: 'Gonzo in Brazil', url: 'https://www.legalporno.com/studios/gonzo-in-brazil', parent: 'legalporno', }, { slug: 'mranal', name: 'Mr Anal', url: 'https://www.legalporno.com/studios/mr-anal', parent: 'legalporno', }, { slug: 'tarrawhite', name: 'Tarra White', url: 'https://www.legalporno.com/studios/tarra-white', parent: 'legalporno', }, { slug: 'sineplexsos', name: 'Sineplex SOS', url: 'https://www.legalporno.com/studios/sineplex-sos', parent: 'legalporno', }, { slug: 'fmodels', name: 'F Models', url: 'https://www.legalporno.com/studios/f-models', parent: 'legalporno', }, { slug: 'sineplexcz', name: 'Sineplex CZ', url: 'https://www.legalporno.com/studios/sineplex-cz', parent: 'legalporno', }, { slug: 'gg', name: 'GG', url: 'https://www.legalporno.com/studios/gg', parent: 'legalporno', }, { slug: 'firstgape', name: 'First Gape', url: 'https://www.legalporno.com/studios/first-gape', parent: 'legalporno', }, { slug: 'omargalantiproductions', name: 'Omar Galanti Productions', url: 'https://www.legalporno.com/studios/omar-galanti-productions', parent: 'legalporno', }, { slug: 'norestfortheass', name: 'No Rest For The Ass', url: 'https://www.legalporno.com/studios/no-rest-for-the-ass', parent: 'legalporno', }, { slug: 'hairygonzo', name: 'Hairy Gonzo', url: 'https://www.legalporno.com/studios/hairy-gonzo', parent: 'legalporno', }, { slug: 'sineplexclassic', name: 'Sineplex Classic', url: 'https://www.legalporno.com/studios/sineplex-classic', parent: 'legalporno', }, { slug: 'sinemale', name: 'Sinemale', url: 'https://www.legalporno.com/studios/sinemale', parent: 'legalporno', }, { slug: 'outsidethestudio', name: 'Outside The Studio', url: 'https://www.legalporno.com/studios/outside-the-studio', parent: 'legalporno', }, { slug: 'kinkysex', name: 'Kinky Sex', url: 'https://www.legalporno.com/studios/kinky-sex', parent: 'legalporno', }, ]; /* eslint-disable max-len */ exports.seed = knex => Promise.resolve() .then(async () => { const networks = await knex('entities') .whereIn('slug', studios.map(studio => studio.parent)); const networksMap = networks.reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {}); const studiosWithNetwork = studios.map(studio => ({ slug: studio.slug, name: studio.name, url: studio.url, type: 'studio', parent_id: networksMap[studio.parent], has_logo: studio.hasLogo || false, })); return upsert('entities', studiosWithNetwork, 'slug', knex); });