diff --git a/web/src/main/java/org/cbioportal/web/TreatmentController.java b/web/src/main/java/org/cbioportal/web/TreatmentController.java index f4b38925ba4..c17ecda37f2 100644 --- a/web/src/main/java/org/cbioportal/web/TreatmentController.java +++ b/web/src/main/java/org/cbioportal/web/TreatmentController.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Set; @PublicApi @RestController @@ -151,12 +152,18 @@ public ResponseEntity getContainsTreatmentData( @ApiParam(required = true, value = "List of Study IDs") @Size(min = 1, max = PagingConstants.MAX_PAGE_SIZE) @RequestBody - List studyIds + Set studyIds ) { - Boolean containsTreatmentData = treatmentService.containsTreatmentData(studyIds, tier); + Boolean containsTreatmentData = instance.cacheableGetContainsTreatmentData(studyIds, tier); return new ResponseEntity<>(containsTreatmentData, HttpStatus.OK); } + // Caching enabled for any number of studies as the requests contains only studyIds and the response is a boolean + @Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()") + public Boolean cacheableGetContainsTreatmentData(Set studyIds, ClinicalEventKeyCode tier) { + return treatmentService.containsTreatmentData(new ArrayList<>(studyIds), tier); + } + @PreAuthorize("hasPermission(#studyIds, 'Collection', T(org.cbioportal.utils.security.AccessLevel).READ)") @RequestMapping(value = "/treatments/display-sample", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation("Should sample level treatments be displayed") @@ -168,9 +175,14 @@ public ResponseEntity getContainsSampleTreatmentData( @ApiParam(required = true, value = "List of Study IDs") @Size(min = 1, max = PagingConstants.MAX_PAGE_SIZE) @RequestBody - List studyIds + Set studyIds ) { - Boolean containsTreatmentData = treatmentService.containsSampleTreatmentData(studyIds, tier); + Boolean containsTreatmentData = instance.cacheableGetContainsSampleTreatmentData(studyIds, tier); return new ResponseEntity<>(containsTreatmentData, HttpStatus.OK); } + + @Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()") + public Boolean cacheableGetContainsSampleTreatmentData(Set studyIds, ClinicalEventKeyCode tier) { + return treatmentService.containsSampleTreatmentData(new ArrayList<>(studyIds), tier); + } }