Add v2 snapshot schema validation and import_snapshots command
This commit is contained in:
23
apps/ingestion/management/commands/import_snapshots.py
Normal file
23
apps/ingestion/management/commands/import_snapshots.py
Normal file
@ -0,0 +1,23 @@
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from apps.ingestion.services.snapshot_import import SnapshotImporter
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Import static JSON snapshots from incoming directory into PostgreSQL."
|
||||
|
||||
def handle(self, *args, **options):
|
||||
importer = SnapshotImporter(
|
||||
incoming_dir=settings.STATIC_DATASET_INCOMING_DIR,
|
||||
archive_dir=settings.STATIC_DATASET_ARCHIVE_DIR,
|
||||
failed_dir=settings.STATIC_DATASET_FAILED_DIR,
|
||||
)
|
||||
run = importer.run()
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
f"Import run {run.id} completed: status={run.status} "
|
||||
f"files={run.files_processed}/{run.files_total} "
|
||||
f"rows_upserted={run.rows_upserted} rows_failed={run.rows_failed}"
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user