refactor(dolt): pass run_id to SourceImporter.promote
Both real target tables (fundamental_snapshots, earnings_events) carry an import_run_id; stamping requires the current run's id. A2 (the earnings importer) is the first real consumer, so promote gains a run_id argument rather than having importers hack the running row out of the framework. Protocol + call site updated; the A1 fake importer now stamps and asserts import_run_id. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -94,9 +94,11 @@ class SourceImporter(Protocol):
|
||||
"""Run the source's validation gates against ``staged``. Read-only."""
|
||||
...
|
||||
|
||||
async def promote(self, db: AsyncSession, staged: Any) -> dict[str, int]:
|
||||
async def promote(self, db: AsyncSession, staged: Any, run_id: int) -> dict[str, int]:
|
||||
"""Apply ``staged`` to the live tables. Called inside the promotion
|
||||
transaction; the caller commits. Returns row-count deltas."""
|
||||
transaction; the caller commits. ``run_id`` is the current
|
||||
``data_import_runs.id`` so written rows can be stamped with their
|
||||
``import_run_id``. Returns row-count deltas."""
|
||||
...
|
||||
|
||||
|
||||
@@ -213,7 +215,7 @@ async def run_import(
|
||||
return run
|
||||
|
||||
# Promotion: importer writes + run-row flip in one transaction.
|
||||
row_counts = await importer.promote(session, staged)
|
||||
row_counts = await importer.promote(session, staged, run.id)
|
||||
run.status = STATUS_PROMOTED
|
||||
run.row_counts_json = json.dumps(row_counts, default=str)
|
||||
run.completed_at = _now()
|
||||
|
||||
Reference in New Issue
Block a user