Upgraded dependencies, bumped to Node 24.
This commit is contained in:
35
src/sync.js
35
src/sync.js
@@ -1,12 +1,13 @@
|
||||
import process from 'node:process';
|
||||
import config from 'config';
|
||||
import { format } from 'date-fns';
|
||||
import { CronJob } from 'cron';
|
||||
import { format } from 'date-fns';
|
||||
|
||||
import initLogger from './logger.js';
|
||||
import { knexOwner as knex } from './knex.js';
|
||||
import { searchApi, indexApi } from './manticore.js';
|
||||
import chunk from '../utils/chunk.js';
|
||||
import filterTitle from '../utils/filter-title.js';
|
||||
import { knexOwner as knex } from './knex.js';
|
||||
import initLogger from './logger.js';
|
||||
import { indexApi, searchApi } from './manticore.js';
|
||||
|
||||
const logger = initLogger();
|
||||
|
||||
@@ -31,7 +32,7 @@ export async function syncStashes(domain = 'scene', ids) {
|
||||
|
||||
const stashDocs = stashChunk.map((stash) => ({
|
||||
replace: {
|
||||
index: `${domain}s_stashed`,
|
||||
table: `${domain}s_stashed`,
|
||||
id: stash.stashed_id,
|
||||
doc: {
|
||||
[`${domain}_id`]: stash[`${domain}_id`],
|
||||
@@ -60,7 +61,7 @@ export async function syncStashes(domain = 'scene', ids) {
|
||||
await chain;
|
||||
|
||||
const searchResponse = await searchApi.search({
|
||||
index: `${domain}s_stashed`,
|
||||
table: `${domain}s_stashed`,
|
||||
query: {
|
||||
in: {
|
||||
[`${domain}_id`]: itemIdChunk,
|
||||
@@ -72,7 +73,7 @@ export async function syncStashes(domain = 'scene', ids) {
|
||||
const docs = searchResponse?.hits?.hits ?? [];
|
||||
|
||||
const orphanedIds = docs
|
||||
.map((hit) => hit._id)
|
||||
.map((hit) => hit.id)
|
||||
.filter((manticoreId) => !validStashedIds.has(manticoreId));
|
||||
|
||||
if (orphanedIds.length === 0) {
|
||||
@@ -81,7 +82,7 @@ export async function syncStashes(domain = 'scene', ids) {
|
||||
|
||||
const deleteDocs = orphanedIds.map((orphanId) => ({
|
||||
delete: {
|
||||
index: `${domain}s_stashed`,
|
||||
table: `${domain}s_stashed`,
|
||||
id: orphanId,
|
||||
},
|
||||
}));
|
||||
@@ -93,7 +94,7 @@ export async function syncStashes(domain = 'scene', ids) {
|
||||
}
|
||||
|
||||
export async function syncManticoreScenes(sceneIds) {
|
||||
logger.info(`Updating Manticore search documents for ${sceneIds ? sceneIds.length : 'all' } scenes`);
|
||||
logger.info(`Updating Manticore search documents for ${sceneIds ? sceneIds.length : 'all'} scenes`);
|
||||
|
||||
const scenes = await knex.raw(`
|
||||
SELECT
|
||||
@@ -177,7 +178,7 @@ export async function syncManticoreScenes(sceneIds) {
|
||||
if (!scene) {
|
||||
return {
|
||||
delete: {
|
||||
index: 'scenes',
|
||||
table: 'scenes',
|
||||
id: sceneId,
|
||||
},
|
||||
};
|
||||
@@ -216,7 +217,7 @@ export async function syncManticoreScenes(sceneIds) {
|
||||
|
||||
return {
|
||||
replace: {
|
||||
index: 'scenes',
|
||||
table: 'scenes',
|
||||
id: scene.id,
|
||||
doc: {
|
||||
title: scene.title || undefined,
|
||||
@@ -279,7 +280,7 @@ export async function syncScenes(releaseIds) {
|
||||
}
|
||||
|
||||
export async function syncManticoreMovies(movieIds) {
|
||||
logger.info(`Updating Manticore search documents for ${movieIds ? movieIds.length : 'all' } movies`);
|
||||
logger.info(`Updating Manticore search documents for ${movieIds ? movieIds.length : 'all'} movies`);
|
||||
|
||||
const movies = await knex.raw(`
|
||||
SELECT
|
||||
@@ -343,7 +344,7 @@ export async function syncManticoreMovies(movieIds) {
|
||||
if (!movie) {
|
||||
return {
|
||||
delete: {
|
||||
index: 'movies',
|
||||
table: 'movies',
|
||||
id: movieId,
|
||||
},
|
||||
};
|
||||
@@ -362,7 +363,7 @@ export async function syncManticoreMovies(movieIds) {
|
||||
|
||||
return {
|
||||
replace: {
|
||||
index: 'movies',
|
||||
table: 'movies',
|
||||
id: movie.id,
|
||||
doc: {
|
||||
title: movie.title || undefined,
|
||||
@@ -406,7 +407,7 @@ export async function syncMovies(releaseIds) {
|
||||
}
|
||||
|
||||
export async function syncManticoreActors(actorIds) {
|
||||
logger.info(`Updating Manticore search documents for ${actorIds ? actorIds.length : 'all' } actors`);
|
||||
logger.info(`Updating Manticore search documents for ${actorIds ? actorIds.length : 'all'} actors`);
|
||||
|
||||
// manually select date of birth, otherwise it is retrieved in local timezone but interpreted as UTC...
|
||||
const actors = await knex.raw(`
|
||||
@@ -430,7 +431,7 @@ export async function syncManticoreActors(actorIds) {
|
||||
if (!actor) {
|
||||
return {
|
||||
delete: {
|
||||
index: 'actors',
|
||||
table: 'actors',
|
||||
id: actorId,
|
||||
},
|
||||
};
|
||||
@@ -438,7 +439,7 @@ export async function syncManticoreActors(actorIds) {
|
||||
|
||||
return {
|
||||
replace: {
|
||||
index: 'actors',
|
||||
table: 'actors',
|
||||
id: actor.id,
|
||||
doc: {
|
||||
entity_id: actor.entity_id || undefined,
|
||||
|
||||
Reference in New Issue
Block a user