Skip to content

Commit

Permalink
fix divide by 0 on rate
Browse files Browse the repository at this point in the history
  • Loading branch information
Didier Durand committed Feb 28, 2024
1 parent 46ae373 commit d9a8239
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/q_list_data_source_sync_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ def list_data_source_sync_jobs_with_details(app_id: str = "", idx_id: str = "",
job["duration"] = duration
job["duration_s"] = duration.seconds
if "metrics" in job and "documentsScanned" in job["metrics"]:
scan_rate = int(job["metrics"]["documentsScanned"]) / int(duration.seconds)
job["metrics"]["scanRate"] = str(scan_rate)
job["metrics"]["averageDocumentScanDuration"] = str(1 / scan_rate)
if duration.seconds > 0:
scan_rate = int(job["metrics"]["documentsScanned"]) / int(duration.seconds)
job["metrics"]["scanRate"] = str(scan_rate)
if scan_rate > 0:
job["metrics"]["averageDocumentScanDuration"] = str(1 / scan_rate)
return jobs
return None

Expand Down

0 comments on commit d9a8239

Please sign in to comment.