Fixed failed hash duplicate source breaking media association.
This commit is contained in:
parent
a2ff12a636
commit
13d02a44e5
|
@ -353,8 +353,6 @@ async function extractSource(baseSource, { existingExtractMediaByUrl }) {
|
||||||
if (typeof baseSource.defer === 'function') {
|
if (typeof baseSource.defer === 'function') {
|
||||||
const src = await baseSource.defer();
|
const src = await baseSource.defer();
|
||||||
|
|
||||||
console.log('DEFERED', src);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...baseSource,
|
...baseSource,
|
||||||
...toBaseSource(src),
|
...toBaseSource(src),
|
||||||
|
@ -909,7 +907,7 @@ async function associateReleaseMedia(releases, type = 'release') {
|
||||||
.reduce((acc, [releaseId, releaseBaseMedias]) => {
|
.reduce((acc, [releaseId, releaseBaseMedias]) => {
|
||||||
releaseBaseMedias.forEach((baseMedia) => {
|
releaseBaseMedias.forEach((baseMedia) => {
|
||||||
const media = storedMediasById[baseMedia.id];
|
const media = storedMediasById[baseMedia.id];
|
||||||
const mediaId = media?.use || media?.entry?.id;
|
const mediaId = (storedMediasById[media?.use] && media?.use) || media?.entry?.id;
|
||||||
|
|
||||||
if (mediaId) {
|
if (mediaId) {
|
||||||
acc.push({
|
acc.push({
|
||||||
|
|
|
@ -217,7 +217,7 @@ function gender() {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function actors(release) {
|
function generateActors(release) {
|
||||||
const length = release.tags.some((tag) => ['dp', 'dap', 'gangbang'].includes(tag))
|
const length = release.tags.some((tag) => ['dp', 'dap', 'gangbang'].includes(tag))
|
||||||
? Math.floor(Math.random() * 6) + 3
|
? Math.floor(Math.random() * 6) + 3
|
||||||
: Math.floor(Math.random() * 3) + 2;
|
: Math.floor(Math.random() * 3) + 2;
|
||||||
|
@ -233,13 +233,20 @@ function actors(release) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function beforeFetchLatest() {
|
async function beforeFetchLatest() {
|
||||||
const tags = await knex('tags')
|
const [actors, tags] = await Promise.all([
|
||||||
.select('name')
|
knex('actors')
|
||||||
.where('priority', '>', 7)
|
.select('name')
|
||||||
.orderByRaw('random()')
|
.orderByRaw('random()')
|
||||||
.pluck('name');
|
.limit(1000)
|
||||||
|
.pluck('name'),
|
||||||
|
knex('tags')
|
||||||
|
.select('name')
|
||||||
|
.where('priority', '>', 7)
|
||||||
|
.orderByRaw('random()')
|
||||||
|
.pluck('name'),
|
||||||
|
]);
|
||||||
|
|
||||||
return { tags };
|
return { actors, tags };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchLatest(entity, page, options) {
|
async function fetchLatest(entity, page, options) {
|
||||||
|
@ -269,13 +276,13 @@ async function fetchLatest(entity, page, options) {
|
||||||
release.photos = photos.map((photo) => `http://${config.web.host}:${config.web.port}/img/${photo}?id=${nanoid()}`);
|
release.photos = photos.map((photo) => `http://${config.web.host}:${config.web.port}/img/${photo}?id=${nanoid()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
release.tags = shuffle(options.beforeFetchLatest.tags).slice(faker.datatype.number({ min: 3, max: 20 }));
|
release.tags = shuffle(options.beforeFetchLatest.tags).slice(0, faker.datatype.number({ min: 3, max: 20 }));
|
||||||
|
|
||||||
|
// release.actors = [...generateActors(release), null]; // include empty actor to ensure proper handling
|
||||||
|
release.actors = shuffle(options.beforeFetchLatest.actors).slice(0, faker.datatype.number(release.tags.some((tag) => ['dp', 'dap', 'gangbang'].includes(tag)) ? { min: 3, max: 6 } : { min: 2, max: 3 }));
|
||||||
|
|
||||||
release.actors = [...actors(release), null]; // include empty actor to ensure proper handling
|
|
||||||
release.title = title(release);
|
release.title = title(release);
|
||||||
|
|
||||||
console.log(release.entryId);
|
|
||||||
|
|
||||||
return release;
|
return release;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const pickRandom = require('../utils/pick-random');
|
||||||
|
|
||||||
|
const firstMale = [
|
||||||
|
'John',
|
||||||
|
'James',
|
||||||
|
'Biggus',
|
||||||
|
'Mick',
|
||||||
|
];
|
||||||
|
|
||||||
|
const lastMale = [
|
||||||
|
'Dickus',
|
||||||
|
'Strong',
|
||||||
|
'Slayer',
|
||||||
|
'Gun',
|
||||||
|
'Pistol',
|
||||||
|
];
|
||||||
|
|
||||||
|
const firstFemale = [
|
||||||
|
'Kimmy',
|
||||||
|
'Summer',
|
||||||
|
'Jessica',
|
||||||
|
'Rose',
|
||||||
|
'Sky',
|
||||||
|
'Skye',
|
||||||
|
];
|
||||||
|
|
||||||
|
const lastFemale = [
|
||||||
|
'Olsen',
|
||||||
|
'Flower',
|
||||||
|
'Star',
|
||||||
|
'Dior',
|
||||||
|
];
|
||||||
|
|
||||||
|
const lastGeneric = [
|
||||||
|
'Steele',
|
||||||
|
'White',
|
||||||
|
];
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
const names = Array.from({ length: 1000 }, () => `${pickRandom([...firstMale, ...firstFemale])} ${pickRandom([...lastMale, ...lastFemale, ...lastGeneric])}`);
|
||||||
|
|
||||||
|
console.log(names);
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
Loading…
Reference in New Issue