History imports: parsers, import jobs and the import worker
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 41s
CI / python-package (push) Skipped
CI / assets (push) Successful in 8s
CI / images (push) Successful in 28s
CI / notify (push) Successful in 7s
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 41s
CI / python-package (push) Skipped
CI / assets (push) Successful in 8s
CI / images (push) Successful in 28s
CI / notify (push) Successful in 7s
- Import jobs (import_jobs table): uploaded exports stored gzipped, processed by `flask imports worker`, which claims jobs with SKIP LOCKED, inserts in chunks with progress, supports cancelling and re-queues jobs whose worker died - CSV: lastfm-to-csv (no header) or any header-labelled CSV/TSV with comma, semicolon or tab delimiters; several date formats and Unix seconds/milliseconds - JSON: pages of user.getRecentTracks (e.g. lastfm.ghan.nl), a single recenttracks response, or a flat list; gzipped files accepted - Last.fm API pull (only when LASTFM_API_KEY is set): pages through user.getRecentTracks up to the job's creation time, rate limited, with retries and resume - Imports keep plays older than 14 days, skip empty/future ones and dedupe against existing history - Import metrics and pending/running job gauges Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
e29abe05dd
commit
6fc9d91fa2
9 files changed
+1004
-1
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import logging
|
||||
|
||||
import click
|
||||
from flask import current_app
|
||||
from flask.cli import AppGroup
|
||||
|
||||
imports_cli = AppGroup("imports", help="History imports.")
|
||||
|
||||
|
||||
@imports_cli.command("worker")
|
||||
@click.option("--once", is_flag=True, help="Process waiting jobs, then exit.")
|
||||
@click.option("--poll", default=2.0, show_default=True, help="Seconds between checks when idle.")
|
||||
@click.option("--metrics/--no-metrics", default=True, help="Serve Prometheus metrics.")
|
||||
def worker(once: bool, poll: float, metrics: bool) -> None:
|
||||
"""Process import jobs: uploaded Last.fm exports and pulls from Last.fm."""
|
||||
from scrobbler.services.imports import run_worker
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
||||
if metrics:
|
||||
from scrobbler.metrics.server import start_metrics_server
|
||||
|
||||
start_metrics_server(current_app.config["IMPORT_WORKER_METRICS_PORT"])
|
||||
run_worker(poll_seconds=poll, once=once)
|
||||
Reference in new issue
Block a user