Added separate force media argument.
This commit is contained in:
@@ -9,6 +9,7 @@ const moment = require('moment');
|
||||
|
||||
const knex = require('../knex');
|
||||
const capitalize = require('../utils/capitalize');
|
||||
const shuffle = require('../utils/shuffle');
|
||||
|
||||
function random(array) {
|
||||
return array[Math.floor(Math.random() * array.length)];
|
||||
@@ -231,6 +232,16 @@ function actors(release) {
|
||||
}));
|
||||
}
|
||||
|
||||
async function beforeFetchLatest() {
|
||||
const tags = await knex('tags')
|
||||
.select('name')
|
||||
.where('priority', '>', 7)
|
||||
.orderByRaw('random()')
|
||||
.pluck('name');
|
||||
|
||||
return { tags };
|
||||
}
|
||||
|
||||
async function fetchLatest(entity, page, options) {
|
||||
return Promise.all(Array.from({ length: 10000 }, async (value, index) => {
|
||||
const release = {};
|
||||
@@ -258,20 +269,18 @@ async function fetchLatest(entity, page, options) {
|
||||
release.photos = photos.map((photo) => `http://${config.web.host}:${config.web.port}/img/${photo}?id=${nanoid()}`);
|
||||
}
|
||||
|
||||
release.tags = await knex('tags')
|
||||
.select('name')
|
||||
.where('priority', '>', 7)
|
||||
.orderByRaw('random()')
|
||||
.limit(faker.datatype.number({ min: 15, max: 25 }))
|
||||
.pluck('name');
|
||||
release.tags = shuffle(options.beforeFetchLatest.tags).slice(faker.datatype.number({ min: 3, max: 20 }));
|
||||
|
||||
release.actors = [...actors(release), null]; // include empty actor to ensure proper handling
|
||||
release.title = title(release);
|
||||
|
||||
console.log(release.entryId);
|
||||
|
||||
return release;
|
||||
}));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
beforeFetchLatest,
|
||||
fetchLatest,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user