Can now filter on both group and person.

This commit is contained in:
neviyn 2018-11-01 10:09:02 +00:00
parent ecd3b6772c
commit 2eefe3c217
2 changed files with 6 additions and 1 deletions

View File

@ -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 {

View File

@ -22,6 +22,8 @@ interface ObservationRepository : CrudRepository<Observation, Long> {
fun findByTutorsAndWhomAndDateBetween(tutor: Tutor, whom: String, startDate: LocalDate, endDate: LocalDate): List<Observation>
fun findBySiteAndPersonsAndDateBetween(site: Site, person: Person, startDate: LocalDate, endDate: LocalDate): List<Observation>
fun findBySiteAndWhomAndPersonsAndDateBetween(site: Site, whom: String, person: Person, startDate: LocalDate, endDate: LocalDate): List<Observation>
}
@Repository