From 0d9f81c44a40e8691878252b0b952f5ec3bc482a Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Wed, 27 Dec 2023 09:39:37 +0545 Subject: [PATCH] add humanize response time to responses --- API/api_worker.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/API/api_worker.py b/API/api_worker.py index 005f7778..2a1a343f 100644 --- a/API/api_worker.py +++ b/API/api_worker.py @@ -5,8 +5,9 @@ import shutil import time from datetime import datetime as dt -from datetime import timezone +from datetime import timedelta, timezone +import humanize import requests import sozipfile.sozipfile as zipfile from celery import Celery @@ -40,7 +41,7 @@ def process_raw_data(self, params): params = RawDataCurrentParams(**params) try: - start_time = dt.now() + start_time = time.time() bind_zip = params.bind_zip if ALLOW_BIND_ZIP_FILTER else True # unique id for zip file and geojson for each export params.output_type = ( @@ -172,8 +173,9 @@ def process_raw_data(self, params): if use_s3_to_upload or bind_zip: # remove working dir from the machine , if its inside zip / uploaded we no longer need it remove_file(working_dir) - response_time = dt.now() - start_time - response_time_str = str(response_time) + response_time_str = humanize.naturaldelta( + timedelta(seconds=(time.time() - start_time)) + ) logging.info( f"Done Export : {exportname} of {round(inside_file_size/1000000)} MB / {geom_area} sqkm in {response_time_str}" )