Fixed failed hash duplicate source breaking media association.

This commit is contained in:
DebaucheryLibrarian
2023-07-02 23:59:49 +02:00
parent a2ff12a636
commit 13d02a44e5
3 changed files with 66 additions and 14 deletions

View File

@@ -217,7 +217,7 @@ function gender() {
]);
}
function actors(release) {
function generateActors(release) {
const length = release.tags.some((tag) => ['dp', 'dap', 'gangbang'].includes(tag))
? Math.floor(Math.random() * 6) + 3
: Math.floor(Math.random() * 3) + 2;
@@ -233,13 +233,20 @@ function actors(release) {
}
async function beforeFetchLatest() {
const tags = await knex('tags')
.select('name')
.where('priority', '>', 7)
.orderByRaw('random()')
.pluck('name');
const [actors, tags] = await Promise.all([
knex('actors')
.select('name')
.orderByRaw('random()')
.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) {
@@ -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.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);
console.log(release.entryId);
return release;
}));
}