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

Cache treatment endpoints #10282

Merged
merged 1 commit into from
Jul 26, 2023
Merged
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
20 changes: 16 additions & 4 deletions web/src/main/java/org/cbioportal/web/TreatmentController.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;

@PublicApi
@RestController
Expand Down Expand Up @@ -151,12 +152,18 @@ public ResponseEntity<Boolean> getContainsTreatmentData(
@ApiParam(required = true, value = "List of Study IDs")
@Size(min = 1, max = PagingConstants.MAX_PAGE_SIZE)
@RequestBody
List<String> studyIds
Set<String> 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<String> studyIds, ClinicalEventKeyCode tier) {
return treatmentService.containsTreatmentData(new ArrayList<>(studyIds), tier);
}

@PreAuthorize("hasPermission(#studyIds, 'Collection<CancerStudyId>', 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")
Expand All @@ -168,9 +175,14 @@ public ResponseEntity<Boolean> getContainsSampleTreatmentData(
@ApiParam(required = true, value = "List of Study IDs")
@Size(min = 1, max = PagingConstants.MAX_PAGE_SIZE)
@RequestBody
List<String> studyIds
Set<String> 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<String> studyIds, ClinicalEventKeyCode tier) {
return treatmentService.containsSampleTreatmentData(new ArrayList<>(studyIds), tier);
}
}