Refactored various modules for entities. Updated and refactored Kink scraper.
This commit is contained in:
@@ -153,17 +153,13 @@ function getStudios(networksMap) {
|
||||
/* eslint-disable max-len */
|
||||
exports.seed = knex => Promise.resolve()
|
||||
.then(async () => {
|
||||
const [networks, types] = await Promise.all([
|
||||
knex('entities').select('*'),
|
||||
knex('entities_types').select('*'),
|
||||
]);
|
||||
const networks = await knex('entities').select('*').where('type', 'network');
|
||||
|
||||
const networksMap = networks.reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
const typesMap = types.reduce((acc, type) => ({ [type.type]: type.id }), {});
|
||||
|
||||
const studios = getStudios(networksMap).map(studio => ({
|
||||
...studio,
|
||||
type: typesMap.studio,
|
||||
type: 'studio',
|
||||
}));
|
||||
|
||||
return upsert('entities', studios, 'slug', knex);
|
||||
|
||||
Reference in New Issue
Block a user