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,58 @@
|
||||
"""import jobs
|
||||
|
||||
Revision ID: e7fb730bac15
|
||||
Revises: d6113d27cce6
|
||||
Create Date: 2026-09-25 14:59:23.375055
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'e7fb730bac15'
|
||||
down_revision = 'd6113d27cce6'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('import_jobs',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('source', sa.String(length=16), nullable=False),
|
||||
sa.Column('status', sa.String(length=16), nullable=False),
|
||||
sa.Column('filename', sa.String(length=255), nullable=True),
|
||||
sa.Column('lastfm_username', sa.String(length=64), nullable=True),
|
||||
sa.Column('payload', sa.LargeBinary(), nullable=True),
|
||||
sa.Column('total', sa.Integer(), nullable=True),
|
||||
sa.Column('processed', sa.Integer(), nullable=False),
|
||||
sa.Column('imported', sa.Integer(), nullable=False),
|
||||
sa.Column('duplicates', sa.Integer(), nullable=False),
|
||||
sa.Column('skipped', sa.Integer(), nullable=False),
|
||||
sa.Column('error', sa.Text(), nullable=True),
|
||||
sa.Column('next_page', sa.Integer(), nullable=True),
|
||||
sa.Column('pull_until', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('started_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('finished_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('heartbeat_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
with op.batch_alter_table('import_jobs', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_import_jobs_status'), ['status'], unique=False)
|
||||
batch_op.create_index(batch_op.f('ix_import_jobs_user_id'), ['user_id'], unique=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('import_jobs', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_import_jobs_user_id'))
|
||||
batch_op.drop_index(batch_op.f('ix_import_jobs_status'))
|
||||
|
||||
op.drop_table('import_jobs')
|
||||
# ### end Alembic commands ###
|
||||
Reference in new issue
Block a user