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: 'marywet', name: 'Marywet', url: 'https://www.legalporno.com/studios/marywet', 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', }, { slug: 'sexyangelproductions', name: 'Sexy Angel Productions', url: 'https://www.legalporno.com/studios/sexy-angel-productions', parent: 'legalporno', }, { slug: 'nfstudio', name: 'N&F Studio', url: 'https://www.legalporno.com/studios/nf-studio', parent: 'legalporno', }, { slug: 'natashateenproductions', name: 'Natasha Teen Productions', url: 'https://www.legalporno.com/studios/natasha-teen-productions', parent: 'legalporno', }, { slug: 'mixedstudios', name: 'Mixed Studios', url: 'https://www.legalporno.com/studios/mixed-studios', parent: 'legalporno', }, { slug: 'claudiasclips', name: 'Claudia\'s Clips', url: 'https://www.legalporno.com/studios/claudia--s-clips', parent: 'legalporno', }, { slug: 'rebeccasclips', name: 'Rebecca\'s Clips', url: 'https://www.legalporno.com/studios/rebecca--s-clips', parent: 'legalporno', }, { slug: 'private', name: 'Private', url: 'https://www.legalporno.com/studios/private', parent: 'legalporno', }, { slug: 'privatecastings', name: 'Private Castings', url: 'https://www.legalporno.com/studios/private-castings', parent: 'legalporno', }, { slug: 'privateblack', name: 'Private Black', url: 'https://www.legalporno.com/studios/private-black', 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', 'type'], knex); });