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}" ) )