From c67b1565623419de9ed4f365846c565b63f4b688 Mon Sep 17 00:00:00 2001 From: Victor Rocheleau Date: Wed, 17 Jul 2024 19:16:33 +0000 Subject: [PATCH 1/2] fix: biosamples search total count --- chord_metadata_service/discovery/stats.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/chord_metadata_service/discovery/stats.py b/chord_metadata_service/discovery/stats.py index 9200e393c..4a38ed656 100644 --- a/chord_metadata_service/discovery/stats.py +++ b/chord_metadata_service/discovery/stats.py @@ -60,18 +60,15 @@ async def bento_public_format_count_and_stats_list( async for q in annotated_queryset: label = q["label"] - value = thresholded_count(int(q["value"]), discovery, low_counts_censored) + raw_value = int(q["value"]) + thresholded_value = thresholded_count(int(q["value"]), discovery, low_counts_censored) - # Be careful not to leak values if they're in the database but below threshold - if value == 0: - continue + # increment with raw count for accurate total + total += raw_value - # Skip 'missing' values - if label is None: - continue - - total += value - stats_list.append({"label": label, "value": value}) + # Be careful not to leak values if they're in the database but below threshold + if label is not None and thresholded_value > 0: + stats_list.append({"label": label, "value": thresholded_value}) return thresholded_count(total, discovery, low_counts_censored), stats_list From 00cf6e712f3ba995e3de591a5e3f2bd4976f9725 Mon Sep 17 00:00:00 2001 From: Victor Rocheleau Date: Wed, 17 Jul 2024 19:34:22 +0000 Subject: [PATCH 2/2] chore: bump version to 8.0.1 --- chord_metadata_service/discovery/stats.py | 3 ++- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/chord_metadata_service/discovery/stats.py b/chord_metadata_service/discovery/stats.py index 4a38ed656..5709fce47 100644 --- a/chord_metadata_service/discovery/stats.py +++ b/chord_metadata_service/discovery/stats.py @@ -58,10 +58,11 @@ async def bento_public_format_count_and_stats_list( stats_list: list[BinWithValue] = [] total: int = 0 + # TODO: improve censorship tests for search/beacon counts/stats async for q in annotated_queryset: label = q["label"] raw_value = int(q["value"]) - thresholded_value = thresholded_count(int(q["value"]), discovery, low_counts_censored) + thresholded_value = thresholded_count(raw_value, discovery, low_counts_censored) # increment with raw count for accurate total total += raw_value diff --git a/pyproject.toml b/pyproject.toml index 3292d46ed..38f6aa826 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "chord_metadata_service" # can be renamed to katsu if inner module directory is renamed too -version = "8.0.0" +version = "8.0.1" description = "An implementation of a clin/pheno metadata store for the Bento platform." authors = [ "Ksenia Zaytseva",