Refreshing entity slug cache in seeds. Added Hardwerk to Radical.
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
const upsert = require('../src/utils/upsert');
|
||||
const redis = require('../src/redis');
|
||||
|
||||
const entityPrefixes = {
|
||||
channel: '',
|
||||
network: '_',
|
||||
studio: '*',
|
||||
info: '@',
|
||||
};
|
||||
|
||||
/* eslint-disable max-len */
|
||||
const sites = [
|
||||
@@ -10554,6 +10562,18 @@ const sites = [
|
||||
siteAsSerie: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Hardwerk',
|
||||
slug: 'hardwerk',
|
||||
url: 'https://hardwerk.com',
|
||||
independent: true,
|
||||
parent: 'radical',
|
||||
parameters: {
|
||||
endpoint: 'jC4SrjH8YVDtRejiA0PMx',
|
||||
videos: 'films',
|
||||
actors: 'performers',
|
||||
},
|
||||
},
|
||||
// REALITY KINGS
|
||||
{
|
||||
name: 'Look At Her Now',
|
||||
@@ -15540,195 +15560,86 @@ sites.reduce((acc, site) => {
|
||||
}, new Set());
|
||||
|
||||
/* eslint-disable max-len */
|
||||
exports.seed = (knex) => Promise.resolve()
|
||||
.then(async () => {
|
||||
await Promise.all(sites.map(async (channel) => {
|
||||
if (channel.rename) {
|
||||
await knex('entities')
|
||||
.where({
|
||||
type: channel.type || 'channel',
|
||||
slug: channel.rename,
|
||||
})
|
||||
.update('slug', channel.slug);
|
||||
exports.seed = async (knex) => {
|
||||
await Promise.all(sites.map(async (channel) => {
|
||||
if (channel.rename) {
|
||||
await knex('entities')
|
||||
.where({
|
||||
type: channel.type || 'channel',
|
||||
slug: channel.rename,
|
||||
})
|
||||
.update('slug', channel.slug);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (channel.delete) {
|
||||
await knex('entities')
|
||||
.where({
|
||||
type: channel.type || 'channel',
|
||||
slug: channel.slug,
|
||||
})
|
||||
.delete();
|
||||
}
|
||||
}).filter(Boolean));
|
||||
|
||||
const networks = await knex('entities')
|
||||
.where('type', 'network')
|
||||
.orWhereNull('parent_id');
|
||||
|
||||
const networksMap = networks.filter((network) => !network.delete).reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
|
||||
const tags = await knex('tags').select('*').whereNull('alias_for');
|
||||
const tagsMap = tags.reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
|
||||
const sitesWithNetworks = sites.filter((site) => !site.delete).map((site) => ({
|
||||
slug: site.slug,
|
||||
name: site.name,
|
||||
name_stylized: site.style,
|
||||
type: site.type || 'channel',
|
||||
alias: site.alias,
|
||||
description: site.description,
|
||||
url: site.url,
|
||||
parameters: site.parameters || null,
|
||||
options: site.options,
|
||||
parent_id: networksMap[site.parent] || null,
|
||||
priority: site.priority || 0,
|
||||
independent: !!site.independent,
|
||||
visible: site.visible,
|
||||
showcased: site.showcased,
|
||||
has_logo: site.hasLogo === undefined ? true : site.hasLogo,
|
||||
}));
|
||||
|
||||
const { inserted, updated } = await upsert('entities', sitesWithNetworks, ['slug', 'type'], knex);
|
||||
const sitesMap = [].concat(inserted, updated).reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
|
||||
const tagAssociations = sites.map((site) => (site.tags && !site.delete
|
||||
? site.tags.map((tagSlug) => {
|
||||
const tag = tagsMap[tagSlug];
|
||||
|
||||
if (!tag) {
|
||||
console.warn(`Tag ${tagSlug} for ${site.slug} does not exist`);
|
||||
}
|
||||
|
||||
if (channel.delete) {
|
||||
await knex('entities')
|
||||
.where({
|
||||
type: channel.type || 'channel',
|
||||
slug: channel.slug,
|
||||
})
|
||||
.delete();
|
||||
}
|
||||
}).filter(Boolean));
|
||||
return {
|
||||
entity_id: sitesMap[site.slug],
|
||||
tag_id: tagsMap[tagSlug],
|
||||
inherit: true,
|
||||
};
|
||||
})
|
||||
: []
|
||||
)).flat();
|
||||
|
||||
const networks = await knex('entities')
|
||||
.where('type', 'network')
|
||||
.orWhereNull('parent_id');
|
||||
await upsert('entities_tags', tagAssociations, ['entity_id', 'tag_id'], knex);
|
||||
|
||||
const networksMap = networks.filter((network) => !network.delete).reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
const entities = await knex('entities').select('id', 'slug', 'type');
|
||||
|
||||
const tags = await knex('tags').select('*').whereNull('alias_for');
|
||||
const tagsMap = tags.reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
await redis.connect();
|
||||
|
||||
const sitesWithNetworks = sites.filter((site) => !site.delete).map((site) => ({
|
||||
slug: site.slug,
|
||||
name: site.name,
|
||||
name_stylized: site.style,
|
||||
type: site.type || 'channel',
|
||||
alias: site.alias,
|
||||
description: site.description,
|
||||
url: site.url,
|
||||
parameters: site.parameters || null,
|
||||
options: site.options,
|
||||
parent_id: networksMap[site.parent] || null,
|
||||
priority: site.priority || 0,
|
||||
independent: !!site.independent,
|
||||
visible: site.visible,
|
||||
showcased: site.showcased,
|
||||
has_logo: site.hasLogo === undefined ? true : site.hasLogo,
|
||||
}));
|
||||
await redis.del('traxxx:entities:id_by_slug');
|
||||
await redis.hSet('traxxx:entities:id_by_slug', entities.map((entity) => [`${entityPrefixes[entity.type]}${entity.slug}`, entity.id]));
|
||||
|
||||
const { inserted, updated } = await upsert('entities', sitesWithNetworks, ['slug', 'type'], knex);
|
||||
const sitesMap = [].concat(inserted, updated).reduce((acc, { id, slug }) => ({ ...acc, [slug]: id }), {});
|
||||
|
||||
const tagAssociations = sites.map((site) => (site.tags && !site.delete
|
||||
? site.tags.map((tagSlug) => {
|
||||
const tag = tagsMap[tagSlug];
|
||||
|
||||
if (!tag) {
|
||||
console.warn(`Tag ${tagSlug} for ${site.slug} does not exist`);
|
||||
}
|
||||
|
||||
return {
|
||||
entity_id: sitesMap[site.slug],
|
||||
tag_id: tagsMap[tagSlug],
|
||||
inherit: true,
|
||||
};
|
||||
})
|
||||
: []
|
||||
)).flat();
|
||||
|
||||
return upsert('entities_tags', tagAssociations, ['entity_id', 'tag_id'], knex);
|
||||
});
|
||||
await redis.disconnect();
|
||||
};
|
||||
|
||||
exports.sites = sites;
|
||||
|
||||
/*
|
||||
'X-Art' => 'xart',
|
||||
'met-art' => 'metart',
|
||||
'18og' => '18OnlyGirls',
|
||||
'a1o1' => 'Asian1on1',
|
||||
'add' => 'ManualAddActors',
|
||||
'analb' => 'AnalBeauty',
|
||||
'bgonzo' => 'BangGonzo',
|
||||
'btlbd' => 'BigTitsLikeBigDicks',
|
||||
'bjf' => 'BlowjobFridays',
|
||||
'cws' => 'CzechWifeSwap',
|
||||
'Daughter' => 'DaughterSwap',
|
||||
'Daughters' => 'DaughterSwap',
|
||||
'dc' => 'DorcelVision',
|
||||
'dpg' => 'DigitalPlayground',
|
||||
'dsw' => 'DaughterSwap',
|
||||
'faq' => 'FirstAnalQuest',
|
||||
'ft' => 'FastTimes',
|
||||
'fittingroom' => 'Fitting-Room',
|
||||
'gbcp' => 'GangbangCreampie',
|
||||
'hart' => 'Hegre',
|
||||
'hegre-art' => 'Hegre',
|
||||
'kha' => 'KarupsHA',
|
||||
'kow' => 'KarupsOW',
|
||||
'kpc' => 'KarupsPC',
|
||||
'la' => 'LatinAdultery',
|
||||
'lcd' => 'LittleCaprice',
|
||||
'lhf' => 'LoveHerFeet',
|
||||
'littlecapricedreams' => 'Little Caprice Dreams',
|
||||
'maj' => 'ManoJob',
|
||||
'mfl' => 'Mofos',
|
||||
'mj' => 'ManoJob',
|
||||
'mpov' => 'MrPOV',
|
||||
'naughtyamericavr' => 'NaughtyAmerica',
|
||||
'news' => 'NewSensations',
|
||||
'ps' => 'PropertySex',
|
||||
'sart' => 'SexArt',
|
||||
'sbj' => 'StreetBlowjobs',
|
||||
'sislove' => 'SisLovesMe',
|
||||
'tds' => 'TheDickSuckers',
|
||||
'these' => 'TheStripperExperience',
|
||||
'tlc' => 'TeensLoveCream',
|
||||
'tle' => 'TheLifeErotic',
|
||||
'tog' => 'TonightsGirlfriend',
|
||||
'wowg' => 'WowGirls',
|
||||
'wy' => 'WebYoung',
|
||||
'itc' => 'InTheCrack',
|
||||
"abbw" => "AbbyWinters",
|
||||
"abme" => "AbuseMe",
|
||||
"ana" => "AnalAngels",
|
||||
"atke" => "ATKExotics",
|
||||
"atkg" => "ATKGalleria",
|
||||
"atkgfs" => "ATKGirlfriends",
|
||||
"atkh" => "ATKHairy",
|
||||
"aktp" => "ATKPetites",
|
||||
"ba" => "Beauty-Angels",
|
||||
"bna" => "BrandNew",
|
||||
"bam" => "BruceAndMorgan",
|
||||
"bcast" => "BrutalCastings",
|
||||
"bd" => "BrutalDildos",
|
||||
"bpu" => "BrutalPickups",
|
||||
"cza" => "CzhecAmateurs",
|
||||
"czbb" => "CzechBangBus",
|
||||
"czb" => "CzechBitch",
|
||||
"cc" => "CzechCasting",
|
||||
"czc" => "CzechCouples",
|
||||
"czestro" => "CzechEstrogenolit",
|
||||
"czf" => "CzechFantasy",
|
||||
"czgb" => "CzechGangBang",
|
||||
"cgfs" => "CzechGFS",
|
||||
"czharem" => "CzechHarem",
|
||||
"czm" => "CzechMassage",
|
||||
"czo" => "CzechOrgasm",
|
||||
"czps" => "CzechPawnShop",
|
||||
"css" => "CzechStreets",
|
||||
"cztaxi" => "CzechTaxi",
|
||||
"czt" => "CzechTwins",
|
||||
"dts" => "DeepThroatSirens",
|
||||
"doan" => "DiaryOfANanny",
|
||||
"ds" => "DungeonSex",
|
||||
"ffr" => "FacialsForever",
|
||||
"ff" => "FilthyFamily",
|
||||
"fbbg" => "FirstBGG",
|
||||
"fs" => "FuckStudies",
|
||||
"tfcp" => "FullyClothedPissing",
|
||||
"gdp" => "GirlsDoPorn",
|
||||
"Harmony" => "HarmonyVision",
|
||||
"hletee" => "HelplessTeens",
|
||||
"jlmf" => "JessieLoadsMonsterFacials",
|
||||
"lang" => "LANewGirl",
|
||||
"mmp" => "MMPNetwork",
|
||||
"mbc" => "MyBabysittersClub",
|
||||
"nvg" => "NetVideoGirls",
|
||||
"oo" => "Only-Opaques",
|
||||
"os" => "Only-Secretaries",
|
||||
"oss" => "OnlySilAndSatin",
|
||||
"psus" => "PascalsSubSluts",
|
||||
"psp" => "PorsntarsPunishment",
|
||||
"pdmqfo" => "QuestForOrgasm",
|
||||
"sed" => "SexualDisgrace",
|
||||
"sislov" => "SisLovesMe",
|
||||
"tslw" => "SlimeWave",
|
||||
"stre" => "StrictRestraint",
|
||||
"t18" => "Taboo18",
|
||||
"tsma" => "TeenSexMania",
|
||||
"tsm" => "TeenSexMovs",
|
||||
"ttw" => "TeensInTheWoods",
|
||||
"tgw" => "ThaiGirlsWild",
|
||||
"taob" => "TheArtOfBlowJob",
|
||||
"trwo" => "TheRealWorkout",
|
||||
"tt" => "TryTeens",
|
||||
"vp" => "VIPissy",
|
||||
"wrh" => "WeAreHairy",
|
||||
"yt" => "YoungThroats",
|
||||
];
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user