summaryrefslogtreecommitdiff
path: root/app/lib/worker.server.ts
diff options
context:
space:
mode:
authoryyamashita <yyamashita@hetzner.yyamashita.com>2026-08-15 18:57:59 +0900
committeryyamashita <yyamashita@hetzner.yyamashita.com>2026-08-15 18:57:59 +0900
commit59a9f4984c3acd29bc746a78e30849f50fa555ee (patch)
treeb9dab024c0c5d1d68e023b8f49eb0716b97965bd /app/lib/worker.server.ts
parenta100fb28f92fa7c5d2cf701d118c4c7b898c9bf2 (diff)
Add Claude-powered band auto-registration from live info text
Extracts band/artist names from pasted live info via Claude (API or CLI adapter), matches against existing bands, and lets the user review and bulk-register new ones through a polling job queue. Also adds a livehouse events import script and recent-bands/artists home page sections. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'app/lib/worker.server.ts')
-rw-r--r--app/lib/worker.server.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/lib/worker.server.ts b/app/lib/worker.server.ts
new file mode 100644
index 0000000..f71ea40
--- /dev/null
+++ b/app/lib/worker.server.ts
@@ -0,0 +1,32 @@
+import { claimNextParseJob, completeParseJob, failParseJob, listBands } from "./db.server";
+import { parseLiveInfoBands } from "./claude.server";
+
+const POLL_INTERVAL_MS = 2000;
+
+let started = false;
+
+function startWorker() {
+ if (started) return;
+ started = true;
+
+ let busy = false;
+
+ setInterval(async () => {
+ if (busy) return;
+ const job = claimNextParseJob();
+ if (!job) return;
+
+ busy = true;
+ try {
+ const bands = listBands();
+ const matches = await parseLiveInfoBands(job.input_text, bands);
+ completeParseJob(job.id, JSON.stringify(matches));
+ } catch (e) {
+ failParseJob(job.id, e instanceof Error ? e.message : "不明なエラー");
+ } finally {
+ busy = false;
+ }
+ }, POLL_INTERVAL_MS);
+}
+
+startWorker();