From c9e01db63e60847d294fdb31dc865b501f3a3cd4 Mon Sep 17 00:00:00 2001 From: ramari16 Date: Thu, 2 May 2024 15:36:57 -0400 Subject: [PATCH] ALS-6375: Suppress showing user 0 results in open-pic-sure (#193) --- .../AggregateDataSharingResourceRS.java | 17 ++++++++++++++++- ...ateDataSharingResourceRSAcceptanceTests.java | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/main/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRS.java b/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/main/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRS.java index 60b62b5c..4b1b88e8 100644 --- a/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/main/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRS.java +++ b/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/main/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRS.java @@ -522,6 +522,10 @@ protected String processContinuousCrossCounts(String continuousCrossCountRespons int generatedVariance = this.generateVarianceWithCrossCounts(crossCounts); boolean mustObfuscate = isCrossCountObfuscated(crossCounts, generatedVariance); + if (canShowContinuousCrossCounts(crossCounts)) { + return null; + } + // Handle the case where there is no visualization service UUID if (properties.getVisualizationResourceId() != null) { Map> continuousCrossCounts = objectMapper.readValue(continuousCrossCountResponse, new TypeReference<>() {}); @@ -709,6 +713,17 @@ private boolean isCrossCountObfuscated(Map crossCounts, int gene return mustObfuscate; } + + private boolean canShowContinuousCrossCounts(Map crossCounts) { + String lessThanThresholdStr = "< " + this.threshold; + + String v = crossCounts.get("\\_studies_consents\\"); + if (v.contains(lessThanThresholdStr) || v.equals("0")) { + return true; + } + return false; + } + /** * This method will generate a random variance for the request based on the passed entityString. The variance * will be between -variance and +variance. The variance will be generated by adding a random salt to the @@ -765,7 +780,7 @@ private Stream generateParents(String key) { private Optional aggregateCount(String actualCount) { try { int queryResult = Integer.parseInt(actualCount); - if (queryResult > 0 && queryResult < threshold) { + if (queryResult < threshold) { return Optional.of("< " + threshold); } } catch (NumberFormatException nfe) { diff --git a/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/test/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRSAcceptanceTests.java b/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/test/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRSAcceptanceTests.java index 59bddec9..2e88e02b 100644 --- a/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/test/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRSAcceptanceTests.java +++ b/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/test/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRSAcceptanceTests.java @@ -90,7 +90,7 @@ public void testNoObfuscationOnLargeCounts() throws IOException { @Test public void testZeroNotObfuscated() throws IOException { - expect_original_result_to_become_obfuscated_result("all_zero_open_access_cross_count_result", "all_zero_open_access_cross_count_result"); + expect_original_result_to_become_obfuscated_result("all_zero_open_access_cross_count_result", "obfuscated_all_less_ten_open_access_cross_count_result"); } @Test