Fixed empty page breaking Vixen scraper.
This commit is contained in:
@@ -507,8 +507,8 @@ const networks = [
|
||||
|
||||
exports.seed = knex => Promise.resolve()
|
||||
.then(async () => {
|
||||
const { inserted, updated } = await upsert('entities', parentNetworks.map(network => ({ ...network, type: 'network' })), ['slug', 'type'], knex);
|
||||
const parentNetworksBySlug = [].concat(inserted, updated).reduce((acc, network) => ({ ...acc, [network.slug]: network.id }), {});
|
||||
const parentNetworkEntries = await upsert('entities', parentNetworks.map(network => ({ ...network, type: 'network' })), ['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,
|
||||
@@ -521,5 +521,23 @@ exports.seed = knex => Promise.resolve()
|
||||
parent_id: parentNetworksBySlug[network.parent] || null,
|
||||
}));
|
||||
|
||||
return upsert('entities', networksWithParent, ['slug', 'type'], knex);
|
||||
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 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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user