Speed up truth querying
All checks were successful
Build and Publish / build_and_publish (push) Successful in 54s
All checks were successful
Build and Publish / build_and_publish (push) Successful in 54s
This commit is contained in:
parent
301e7b7417
commit
b0325a26b0
1 changed files with 4 additions and 8 deletions
|
@ -114,19 +114,15 @@ def get_all_truths(
|
|||
for key in keys
|
||||
]
|
||||
load_start = time.perf_counter()
|
||||
if limit >= 0:
|
||||
keys = keys[page * limit: (page + 1) * limit]
|
||||
truths = [json.loads(db.get(key)) for key in keys]
|
||||
load_end = time.perf_counter()
|
||||
if limit >= 0:
|
||||
selection = truths[page * limit: (page + 1) * limit]
|
||||
else:
|
||||
selection = truths
|
||||
whittle_end = time.perf_counter()
|
||||
server_timing = "query;dur=%.2f, load;dur=%.2f, whittle;dur=%.2f" % (
|
||||
server_timing = "query;dur=%.2f, load;dur=%.2f" % (
|
||||
(query_end - query_start) * 1000,
|
||||
(load_end - load_start) * 1000,
|
||||
(whittle_end - load_end) * 1000,
|
||||
)
|
||||
return ORJSONResponse(selection, headers={"Server-Timing": server_timing})
|
||||
return ORJSONResponse(truths, headers={"Server-Timing": server_timing})
|
||||
|
||||
|
||||
@truth_router.get("/all", deprecated=True, response_model=list[TruthPayload])
|
||||
|
|
Loading…
Reference in a new issue