forked from DebaucheryLibrarian/traxxx
Added profile interpolate command line argument.
This commit is contained in:
parent
71e76e359a
commit
770e5b75a5
|
@ -436,10 +436,17 @@ async function curateProfile(profile, actor) {
|
|||
}
|
||||
}
|
||||
|
||||
async function interpolateProfiles(actorIds) {
|
||||
async function interpolateProfiles(actorIdsOrNames) {
|
||||
const profiles = await knex('actors_profiles')
|
||||
.select('actors_profiles.*', knex.raw('row_to_json(media) as avatar'))
|
||||
.whereIn('actor_id', actorIds)
|
||||
.leftJoin('actors', 'actors.id', 'actors_profiles.actor_id')
|
||||
.modify((query) => {
|
||||
if (actorIdsOrNames?.length > 0) {
|
||||
query
|
||||
.whereIn('actor_id', actorIdsOrNames.filter(idOrName => typeof idOrName === 'number'))
|
||||
.orWhereIn('actors.name', actorIdsOrNames.filter(idOrName => typeof idOrName === 'string'));
|
||||
}
|
||||
})
|
||||
.leftJoin('media', 'actors_profiles.avatar_media_id', 'media.id');
|
||||
|
||||
const profilesByActorId = profiles.reduce((acc, profile) => ({
|
||||
|
@ -450,6 +457,8 @@ async function interpolateProfiles(actorIds) {
|
|||
],
|
||||
}), {});
|
||||
|
||||
logger.info(`Interpolating ${profiles.length} profiles from ${Object.keys(profilesByActorId).length} actors`);
|
||||
|
||||
const interpolatedProfiles = Object.entries(profilesByActorId).map(([actorId, actorProfiles]) => {
|
||||
// group values from each profile
|
||||
const valuesByProperty = actorProfiles.reduce((acc, profile) => Object
|
||||
|
@ -899,4 +908,5 @@ module.exports = {
|
|||
scrapeActors,
|
||||
searchActors,
|
||||
toBaseActors,
|
||||
interpolateProfiles,
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@ const knex = require('./knex');
|
|||
const fetchUpdates = require('./updates');
|
||||
const { fetchScenes, fetchMovies } = require('./deep');
|
||||
const { storeScenes, storeMovies, updateReleasesSearch } = require('./store-releases');
|
||||
const { scrapeActors } = require('./actors');
|
||||
const { scrapeActors, interpolateProfiles } = require('./actors');
|
||||
const { flushEntities } = require('./entities');
|
||||
const { deleteScenes, deleteMovies, flushBatches } = require('./releases');
|
||||
const { flushOrphanedMedia } = require('./media');
|
||||
|
@ -25,6 +25,10 @@ async function init() {
|
|||
await updateReleasesSearch();
|
||||
}
|
||||
|
||||
if (argv.interpolateProfiles) {
|
||||
await interpolateProfiles(argv.interpolateProfiles);
|
||||
}
|
||||
|
||||
if (argv.flushNetworks || argv.flushChannels) {
|
||||
await flushEntities(argv.flushNetworks, argv.flushChannels);
|
||||
}
|
||||
|
|
|
@ -248,6 +248,11 @@ const { argv } = yargs
|
|||
type: 'boolean',
|
||||
default: false,
|
||||
})
|
||||
.option('interpolate-profiles', {
|
||||
describe: 'Interpolate actor profiles',
|
||||
type: 'array',
|
||||
alias: 'interpolate',
|
||||
})
|
||||
.option('flush-orphaned-media', {
|
||||
describe: 'Remove all orphaned media items from database and disk.',
|
||||
type: 'array',
|
||||
|
|
Loading…
Reference in New Issue