Skip to content
Snippets Groups Projects
Commit 56bdb0ba authored by Eva Bardou's avatar Eva Bardou Committed by Bastien Abadie
Browse files

Retrieve transcriptions from local cache in list_transcriptions

parent f429455e
No related branches found
No related tags found
1 merge request!75Retrieve transcriptions from local cache in list_transcriptions
......@@ -935,9 +935,30 @@ class ElementsWorker(BaseWorker):
), "worker_version should be of type str"
query_params["worker_version"] = worker_version
transcriptions = self.api_client.paginate(
"ListTranscriptions", id=element.id, **query_params
)
if self.cache and recursive is None:
# Checking that we only received query_params handled by the cache
assert set(query_params.keys()) <= {
"worker_version",
}, "When using the local cache, you can only filter by 'worker_version'"
conditions = [("element_id", "=", convert_str_uuid_to_hex(element.id))]
if worker_version:
conditions.append(
("worker_version_id", "=", convert_str_uuid_to_hex(worker_version))
)
transcriptions = self.cache.fetch(
"transcriptions",
where=conditions,
)
else:
if self.cache:
logger.warning(
"'recursive' filter was set, results will be retrieved from the API since the local cache doesn't handle this filter."
)
transcriptions = self.api_client.paginate(
"ListTranscriptions", id=element.id, **query_params
)
return transcriptions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment