Skip to content

Commit

Permalink
ALS-6375: Suppress showing user 0 results in open-pic-sure (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 authored May 2, 2024
1 parent a5ae92b commit c9e01db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Map<String, Integer>> continuousCrossCounts = objectMapper.readValue(continuousCrossCountResponse, new TypeReference<>() {});
Expand Down Expand Up @@ -709,6 +713,17 @@ private boolean isCrossCountObfuscated(Map<String, String> crossCounts, int gene
return mustObfuscate;
}


private boolean canShowContinuousCrossCounts(Map<String, String> 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
Expand Down Expand Up @@ -765,7 +780,7 @@ private Stream<String> generateParents(String key) {
private Optional<String> aggregateCount(String actualCount) {
try {
int queryResult = Integer.parseInt(actualCount);
if (queryResult > 0 && queryResult < threshold) {
if (queryResult < threshold) {
return Optional.of("< " + threshold);
}
} catch (NumberFormatException nfe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c9e01db

Please sign in to comment.