Add the time taken even where there are no hits
This commit is contained in:
parent
6a890723d9
commit
c356f58d8a
|
@ -195,10 +195,22 @@ class StorageBackend(ABC):
|
|||
message = f"Error: {response.info['error']['root_cause'][0]['type']}"
|
||||
message_class = "danger"
|
||||
return {"message": message, "class": message_class}
|
||||
if "took" in response:
|
||||
if response["took"] is None:
|
||||
return None
|
||||
if len(response["hits"]["hits"]) == 0:
|
||||
message = "No results."
|
||||
message_class = "danger"
|
||||
return {"message": message, "class": message_class}
|
||||
time_took = (time.process_time() - start) * 1000
|
||||
# Round to 3 significant figures
|
||||
time_took_rounded = round(
|
||||
time_took, 3 - int(floor(log10(abs(time_took)))) - 1
|
||||
)
|
||||
return {
|
||||
"message": message,
|
||||
"class": message_class,
|
||||
"took": time_took_rounded,
|
||||
}
|
||||
|
||||
# For Druid
|
||||
if "error" in response:
|
||||
|
@ -210,9 +222,6 @@ class StorageBackend(ABC):
|
|||
return context
|
||||
else:
|
||||
return response
|
||||
if "took" in response:
|
||||
if response["took"] is None:
|
||||
return None
|
||||
|
||||
# Removed for now, no point given we have restricted indexes
|
||||
# self.filter_blacklisted(user, response)
|
||||
|
|
Loading…
Reference in New Issue