Updated warning message. Added grandparent networks to network seed file, merged 21Naturals and 21Sextreme into 21Sextury.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable max-len */
|
||||
const upsert = require('../src/utils/upsert');
|
||||
|
||||
const parentNetworks = [
|
||||
const grandParentNetworks = [
|
||||
{
|
||||
slug: 'gamma',
|
||||
name: 'Gamma Entertainment',
|
||||
@@ -36,7 +36,7 @@ const parentNetworks = [
|
||||
},
|
||||
];
|
||||
|
||||
const networks = [
|
||||
const parentNetworks = [
|
||||
{
|
||||
slug: '21sextury',
|
||||
name: '21Sextury',
|
||||
@@ -47,6 +47,9 @@ const networks = [
|
||||
},
|
||||
parent: 'gamma',
|
||||
},
|
||||
];
|
||||
|
||||
const networks = [
|
||||
{
|
||||
slug: '21sextreme',
|
||||
name: '21Sextreme',
|
||||
@@ -55,7 +58,7 @@ const networks = [
|
||||
parameters: {
|
||||
mobile: 'https://m.dpfanatics.com/en/video',
|
||||
},
|
||||
parent: 'gamma',
|
||||
parent: '21sextury',
|
||||
},
|
||||
{
|
||||
slug: '21naturals',
|
||||
@@ -65,7 +68,7 @@ const networks = [
|
||||
parameters: {
|
||||
mobile: 'https://m.dpfanatics.com/en/video',
|
||||
},
|
||||
parent: 'gamma',
|
||||
parent: '21sextury',
|
||||
},
|
||||
{
|
||||
slug: 'adulttime',
|
||||
@@ -512,7 +515,21 @@ const networks = [
|
||||
|
||||
exports.seed = knex => Promise.resolve()
|
||||
.then(async () => {
|
||||
const parentNetworkEntries = await upsert('entities', parentNetworks.map(network => ({ ...network, type: 'network' })), ['slug', 'type'], knex);
|
||||
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 => ({
|
||||
@@ -528,7 +545,15 @@ exports.seed = knex => Promise.resolve()
|
||||
|
||||
const networkEntries = await upsert('entities', networksWithParent, ['slug', 'type'], knex);
|
||||
|
||||
const networkIdsBySlug = [].concat(networkEntries.inserted, networkEntries.updated).reduce((acc, network) => ({ ...acc, [network.slug]: network.id }), {});
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user