Added manticore sync all tool, updated manticore driver.

This commit is contained in:
2026-11-12 02:18:13 +01:00
parent de05075def
commit f5e3a8a2ae
7 changed files with 175 additions and 151 deletions
+3 -3
View File
@@ -14167,9 +14167,9 @@
} }
}, },
"node_modules/manticoresearch": { "node_modules/manticoresearch": {
"version": "10.0.0", "version": "10.2.0",
"resolved": "https://registry.npmjs.org/manticoresearch/-/manticoresearch-10.0.0.tgz", "resolved": "https://registry.npmjs.org/manticoresearch/-/manticoresearch-10.2.0.tgz",
"integrity": "sha512-a6eiAImHjhLLJgDYFRJfw2k4UL+y7ucchCbNN7q3t+6Fo4TvYf+vbS3HOcRv2h5wIFo6yaZ5N09ztKOOGqlhNw==", "integrity": "sha512-dzXZwrSVizGjV4yYjEsuzq4TQqqh9FDaCu173p7wxq2xpHwiSp5FTxiBJcMTUQa1K9Di41RUoDTMWAjUjYYjFA==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/cli": "^7.0.0", "@babel/cli": "^7.0.0",
+10 -17
View File
@@ -1,12 +1,10 @@
import argv from '../src/argv.js'; import argv from '../src/argv.js';
import { knexOwner as knex } from '../src/knex.js';
import { utilsApi } from '../src/manticore.js'; import { utilsApi } from '../src/manticore.js';
import redis from '../src/redis.js';
import { syncManticoreActors } from '../src/sync.js'; import { syncManticoreActors } from '../src/sync.js';
import runTool from './run-tool.js';
async function init() { export async function rebuildActors() {
if (argv.update) {
await utilsApi.sql('drop table if exists actors'); await utilsApi.sql('drop table if exists actors');
// bigint rather than timestamp, which is unsigned 32-bit and wraps dates before 1970 into the 2100s // bigint rather than timestamp, which is unsigned 32-bit and wraps dates before 1970 into the 2100s
await utilsApi.sql(`create table actors( await utilsApi.sql(`create table actors(
@@ -32,18 +30,13 @@ async function init() {
console.log('Recreated actors table, syncing actors...'); console.log('Recreated actors table, syncing actors...');
const data = await syncManticoreActors(); await syncManticoreActors();
console.log('data', data);
await knex.destroy();
await redis.quit(); // sync imports connect to redis, which keeps the process alive
return;
}
await knex.destroy();
await redis.quit(); // sync imports connect to redis, which keeps the process alive
} }
init(); if (import.meta.main) {
runTool(async () => {
if (argv.update) {
await rebuildActors();
}
});
}
+10 -12
View File
@@ -1,11 +1,9 @@
import argv from '../src/argv.js'; import argv from '../src/argv.js';
import { knexOwner as knex } from '../src/knex.js';
import { utilsApi } from '../src/manticore.js'; import { utilsApi } from '../src/manticore.js';
import redis from '../src/redis.js';
import { syncManticoreMovies } from '../src/sync.js'; import { syncManticoreMovies } from '../src/sync.js';
import runTool from './run-tool.js';
async function init() { export async function rebuildMovies() {
if (argv.update) {
await utilsApi.sql('drop table if exists movies'); await utilsApi.sql('drop table if exists movies');
// bigint rather than timestamp, which is unsigned 32-bit and wraps dates before 1970 into the 2100s // bigint rather than timestamp, which is unsigned 32-bit and wraps dates before 1970 into the 2100s
await utilsApi.sql(`create table movies ( await utilsApi.sql(`create table movies (
@@ -36,13 +34,13 @@ async function init() {
console.log('Recreated movies tables, syncing movies...'); console.log('Recreated movies tables, syncing movies...');
const data = await syncManticoreMovies(); await syncManticoreMovies();
console.log('data', data);
}
await knex.destroy();
await redis.quit(); // sync imports connect to redis, which keeps the process alive
} }
init(); if (import.meta.main) {
runTool(async () => {
if (argv.update) {
await rebuildMovies();
}
});
}
+9 -9
View File
@@ -1,11 +1,9 @@
import argv from '../src/argv.js'; import argv from '../src/argv.js';
import { knexOwner as knex } from '../src/knex.js';
import { utilsApi } from '../src/manticore.js'; import { utilsApi } from '../src/manticore.js';
import redis from '../src/redis.js';
import { syncManticoreScenes } from '../src/sync.js'; import { syncManticoreScenes } from '../src/sync.js';
import runTool from './run-tool.js';
async function init() { export async function rebuildScenes() {
if (argv.update) {
await utilsApi.sql('drop table if exists scenes'); await utilsApi.sql('drop table if exists scenes');
// bigint rather than timestamp, which is unsigned 32-bit and wraps dates before 1970 into the 2100s // bigint rather than timestamp, which is unsigned 32-bit and wraps dates before 1970 into the 2100s
await utilsApi.sql(`create table scenes ( await utilsApi.sql(`create table scenes (
@@ -62,10 +60,12 @@ async function init() {
console.log('Recreated scenes tables, syncing scenes...'); console.log('Recreated scenes tables, syncing scenes...');
await syncManticoreScenes(); await syncManticoreScenes();
}
await knex.destroy();
await redis.quit(); // sync imports connect to redis, which keeps the process alive
} }
init(); if (import.meta.main) {
runTool(async () => {
if (argv.update) {
await rebuildScenes();
}
});
}
+5 -7
View File
@@ -1,9 +1,8 @@
import { knexOwner as knex } from '../src/knex.js';
import { utilsApi } from '../src/manticore.js'; import { utilsApi } from '../src/manticore.js';
import redis from '../src/redis.js';
import { syncStashes } from '../src/sync.js'; import { syncStashes } from '../src/sync.js';
import runTool from './run-tool.js';
async function init() { export async function rebuildStashes() {
await utilsApi.sql('drop table if exists scenes_stashed'); await utilsApi.sql('drop table if exists scenes_stashed');
await utilsApi.sql(`create table if not exists scenes_stashed ( await utilsApi.sql(`create table if not exists scenes_stashed (
@@ -36,9 +35,8 @@ async function init() {
await syncStashes('scene'); await syncStashes('scene');
await syncStashes('actor'); await syncStashes('actor');
await syncStashes('movie'); await syncStashes('movie');
await knex.destroy();
await redis.quit(); // sync imports connect to redis, which keeps the process alive
} }
init(); if (import.meta.main) {
runTool(rebuildStashes);
}
+19
View File
@@ -0,0 +1,19 @@
import process from 'node:process';
import { knexOwner as knex } from '../src/knex.js';
import redis from '../src/redis.js';
// runs a command line tool and closes the connections afterwards, the knex pool and redis would otherwise keep the process alive
export default async function runTool(tool) {
try {
await tool();
await knex.destroy();
await redis.quit();
}
catch (error) {
// the manticore client rejects with a plain response object rather than an Error, print the server's message
console.error(error instanceof Error ? error : error?.body?.error || error?.body || error);
process.exit(1);
}
}
+16
View File
@@ -0,0 +1,16 @@
import { rebuildActors } from './manticore-actors.js';
import { rebuildMovies } from './manticore-movies.js';
import { rebuildScenes } from './manticore-scenes.js';
import { rebuildStashes } from './manticore-stashes.js';
import runTool from './run-tool.js';
// recreates and fills every manticore table from postgres, i.e. after a manticore upgrade or on a fresh data directory
runTool(async () => {
// stashes first, the scenes sync also writes scene stashes and fails if their table doesn't exist yet
await rebuildStashes();
await rebuildScenes();
await rebuildMovies();
await rebuildActors();
console.log('Rebuilt all manticore tables');
});