diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt index 8ab7f3d..9f09564 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt @@ -135,7 +135,10 @@ class Controller { } else if (observationsRequest.person != null && observationsRequest.person.isNotEmpty() && observationsRequest.site != null) { val person = personRepository.findByName(observationsRequest.person.toUpperCase()) ?: return listOf() val site = siteRepository.findById(observationsRequest.site).get() - return observationRepository.findBySiteAndPersonsAndDateBetween(site, person, observationsRequest.startDate, observationsRequest.endDate) + return if (observationsRequest.whom == null || observationsRequest.whom.isEmpty()) + observationRepository.findBySiteAndPersonsAndDateBetween(site, person, observationsRequest.startDate, observationsRequest.endDate) + else + observationRepository.findBySiteAndWhomAndPersonsAndDateBetween(site, observationsRequest.whom, person, observationsRequest.startDate, observationsRequest.endDate) } else if (observationsRequest.site != null) { return siteRepository.findById(observationsRequest.site).map { when { diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Repository.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Repository.kt index fcd8124..b06f03f 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Repository.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Repository.kt @@ -22,6 +22,8 @@ interface ObservationRepository : CrudRepository { fun findByTutorsAndWhomAndDateBetween(tutor: Tutor, whom: String, startDate: LocalDate, endDate: LocalDate): List fun findBySiteAndPersonsAndDateBetween(site: Site, person: Person, startDate: LocalDate, endDate: LocalDate): List + + fun findBySiteAndWhomAndPersonsAndDateBetween(site: Site, whom: String, person: Person, startDate: LocalDate, endDate: LocalDate): List } @Repository