Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALS-6375: Suppress showing user 0 results in open-pic-sure #193

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading