Phase 1: lock cron, reload chaud, argon2, providers, IMDb lookup, cache LRU, /health, /metrics, rate limit, UI dark, biome

This commit is contained in:
unfr
2026-04-24 07:35:10 +02:00
parent f9745a2390
commit a184a21f57
36 changed files with 2060 additions and 364 deletions

View File

@@ -3,10 +3,8 @@
import { readFileSync } from 'node:fs';
import { parentPort, workerData } from 'node:worker_threads';
import { LEV_DEL, LEV_INS, LEV_REP, LEV_SCALE, TITLE_TOLERANCE, YEAR_TOLERANCE } from '../config.js';
import { mbLevenshtein, mbStrlen } from './mbLevenshtein.js';
import {
TITLE_TOLERANCE, LEV_INS, LEV_REP, LEV_DEL, LEV_SCALE, YEAR_TOLERANCE,
} from '../config.js';
const TMDB = 0;
const TITLE = 1;
@@ -34,8 +32,11 @@ function loadChunk() {
function score(filteredIn, target, ftiLen) {
if (!target) return 0;
const tlen = mbStrlen(target);
return 100 - (mbLevenshtein(filteredIn, target, LEV_INS, LEV_REP, LEV_DEL) /
(Math.max(ftiLen, tlen) * LEV_SCALE)) * 100;
return (
100 -
(mbLevenshtein(filteredIn, target, LEV_INS, LEV_REP, LEV_DEL) / (Math.max(ftiLen, tlen) * LEV_SCALE)) *
100
);
}
function search({ filteredTitleIn, yearIn }) {
@@ -49,7 +50,11 @@ function search({ filteredTitleIn, yearIn }) {
let ok = false;
for (const y of row[YEAR]) {
const dy = Math.abs(yearIn - y);
if (dy <= YEAR_TOLERANCE) { ok = true; deltaYear = dy; break; }
if (dy <= YEAR_TOLERANCE) {
ok = true;
deltaYear = dy;
break;
}
}
if (!ok) continue;
}
@@ -62,7 +67,7 @@ function search({ filteredTitleIn, yearIn }) {
let pT;
if (fT) {
pT = (fT === fO) ? pO : score(filteredTitleIn, fT, ftiLen);
pT = fT === fO ? pO : score(filteredTitleIn, fT, ftiLen);
} else pT = 0;
let pE;