diff --git a/management/commands/ingester.py b/management/commands/ingester.py index 9065df1..0a513b2 100644 --- a/management/commands/ingester.py +++ b/management/commands/ingester.py @@ -23,6 +23,9 @@ def input_with_timeout(prompt, timeout=30): else: return '' +def current_time(): + return (datetime.now() + timedelta(hours=3)).strftime("%H:%M:%S") + class Command(BaseCommand): help = 'Ingest CSV files into the database' @@ -101,8 +104,7 @@ class Command(BaseCommand): - current_time = (datetime.now() + timedelta(hours=3)).strftime("%H:%M:%S") - self.stdout.write(f"[{current_time}] Starting the data ingestion.") + self.stdout.write(f"[{current_time()}] Starting the data ingestion.") #function that iterates over all catalog files and ingests sources from them async def ingest_files(): @@ -112,7 +114,7 @@ class Command(BaseCommand): for catalog_file in catalog_files: if catalog_file.status == 'INGESTED': - self.stdout.write(f"Skipping {catalog_file.name} as it is already ingested.") + self.stdout.write(f"[{current_time()}]Skipping {catalog_file.name} as it is already ingested.") continue file_path = os.path.join(directory, catalog_file.name) @@ -162,8 +164,8 @@ class Command(BaseCommand): ingested_files_count = await count_ingested_files() - current_time = (datetime.now() + timedelta(hours=3)).strftime("%H:%M:%S") #Timestamp and progress self.stdout.write statement - self.stdout.write(f"[{current_time}] {ingested_files_count}/{len(catalog_files)}") + #Timestamp and progress self.stdout.write statement + self.stdout.write(f"[{current_time()}] {ingested_files_count}/{len(catalog_files)}") # Create a completion flag file with open("ingester_done.flag", "w") as f: