Can now filter on both group and person.
This commit is contained in:
parent
ecd3b6772c
commit
2eefe3c217
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user