Skip to content

Commit

Permalink
Fix for statcan TSS dept filter
Browse files Browse the repository at this point in the history
  • Loading branch information
HamzaAburaneh committed Nov 25, 2024
1 parent baf4322 commit 26f503b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/java/ca/gc/tbs/controller/TopTaskController.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class TopTaskController {
institutionMappings.put("SSC", Arrays.asList("SSC", "PSC", "SHARED SERVICES CANADA", "SERVICES PARTAGÉS CANADA", "SSC / PSC"));
institutionMappings.put("SSHRC", Arrays.asList("SSHRC", "CRSH", "SOCIAL SCIENCES AND HUMANITIES RESEARCH COUNCIL", "CONSEIL DE RECHERCHES EN SCIENCES HUMAINES", "SSHRC / CRSH"));
institutionMappings.put("SST", Arrays.asList("SST", "TSS", "SOCIAL SECURITY TRIBUNAL OF CANADA", "TRIBUNAL DE LA SÉCURITÉ SOCIALE DU CANADA", "SST / TSS"));
institutionMappings.put("STATCAN", Arrays.asList("STATCAN", "STATCAN", "STATISTICS CANADA", "STATISTIQUE CANADA", "StatCan / StatCan", "STATCAN / STATCAN"));
institutionMappings.put("STATCAN", Arrays.asList("STATCAN", "STATISTICS CANADA", "STATISTIQUE CANADA", "StatCan / StatCan", "STATCAN / STATCAN"));
institutionMappings.put("TBS", Arrays.asList("TBS", "SCT", "TREASURY BOARD OF CANADA SECRETARIAT", "SECRÉTARIAT DU CONSEIL DU TRÉSOR DU CANADA", "TBS / SCT"));
institutionMappings.put("TC", Arrays.asList("TC", "TC", "TRANSPORT CANADA", "TRANSPORTS CANADA", "TC / TC"));
institutionMappings.put("VAC", Arrays.asList("VAC", "ACC", "VETERANS AFFAIRS CANADA", "ANCIENS COMBATTANTS CANADA", "VAC / ACC"));
Expand Down Expand Up @@ -410,7 +410,11 @@ private Criteria buildExportCriteria(HttpServletRequest request) {
criteria.and("grouping").is(group);
}
if (department != null && !department.isEmpty()) {
criteria.and("dept").is(department);
if (department.equalsIgnoreCase("STATCAN / STATCAN")) {
criteria.and("dept").is("StatCan / StatCan");
} else {
criteria.and("dept").is(department);
}
}

List<Criteria> combinedOrCriteria = new ArrayList<>();
Expand Down Expand Up @@ -633,6 +637,13 @@ public ResponseEntity<?> getProblemsJson(
}

private Criteria applyDepartmentFilter(Criteria criteria, String department) {
// Special case for StatCan since we know its exact format in DB
if (department.equalsIgnoreCase("STATCAN / STATCAN")) {
criteria.and("dept").is("StatCan / StatCan");
return criteria;
}

// For other departments, use case-insensitive matching
Set<String> matchingVariations = new HashSet<>();
for (Map.Entry<String, List<String>> entry : institutionMappings.entrySet()) {
if (entry.getValue().stream().anyMatch(variation -> variation.equalsIgnoreCase(department))) {
Expand Down

0 comments on commit 26f503b

Please sign in to comment.