Added caching to chart endpoint.
This commit is contained in:
parent
cbdcd80fef
commit
0fcfcfaa09
@ -119,7 +119,7 @@ class Controller {
|
||||
* Get all observations that are within the constraints provided in [observationsRequest].
|
||||
*/
|
||||
@PostMapping("/observations")
|
||||
@Cacheable("observations")
|
||||
@Cacheable("observations", key = "#observationsRequest")
|
||||
fun getObservations(@Valid @RequestBody observationsRequest: ObservationsRequest): List<Observation> {
|
||||
if (observationsRequest.tutor != null) {
|
||||
return tutorRepository.findById(observationsRequest.tutor).map {
|
||||
@ -155,6 +155,7 @@ class Controller {
|
||||
* in a format compatible with ChartJS.
|
||||
*/
|
||||
@PostMapping("/observations/chartdata")
|
||||
@Cacheable("charts", key = "#observationsRequest")
|
||||
fun getObservationsChartData(@Valid @RequestBody observationsRequest: ObservationsRequest): ChartData? {
|
||||
val data = getObservations(observationsRequest)
|
||||
if (data.isEmpty()) return ChartData(listOf(), listOf())
|
||||
|
@ -3,5 +3,6 @@ spring.datasource.url=jdbc:h2:file:./database
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
obsdb.password=observation
|
||||
spring.cache.type=caffeine
|
||||
spring.cache.cache-names=observations
|
||||
spring.cache.cache-names=observations,charts
|
||||
spring.cache.caffeine.spec=maximumSize=500,expireAfterAccess=600s
|
||||
management.endpoints.web.exposure.include=health,info,metrics
|
Loading…
Reference in New Issue
Block a user