Skip to content

Commit

Permalink
Fix format-related Typesense report errors (#342)
Browse files Browse the repository at this point in the history
Don't bother doing a counts of formats, and format versions, of files
matching report criteria if no formats, or format versions, were found
(given that others a multi-search Typesense query will be sent with no
searches and will result in an HTTP 500 error).
  • Loading branch information
mcantelon committed Sep 19, 2024
1 parent 1101201 commit a481446
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion AIPscan/Data/report_data_typesense.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def formats_count(

value_counts = ts_helpers.facet_value_counts(results, "file_format")

# If no formats were found then don't proceed to get counts
if len(value_counts) == 0:
return report

format_size_sums = {}
if include_size_data:
# Request total size of files for each file format
Expand Down Expand Up @@ -216,9 +220,14 @@ def format_versions_count(
)

puid_counts = ts_helpers.facet_value_counts(results, "puid")
puids = list(puid_counts.keys())

# If no format versions were found then don't proceed to get counts
if len(puid_counts) == 0:
return report

# Request total size of files for each PUID
puids = list(puid_counts.keys())

search_requests = {"searches": []}
for puid in puids:
format_filters = file_filters.copy()
Expand Down

0 comments on commit a481446

Please sign in to comment.