From 563bbd17dacfb5b89109cd724308f613693c378e Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Mon, 22 Oct 2018 11:19:58 +0100 Subject: [PATCH] Added check for if person is empty in an observations request. --- .../kotlin/uk/co/neviyn/observationdatabase/Controller.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 cd9e4e6..181423f 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt @@ -133,7 +133,12 @@ class Controller { } }.orElse(listOf()) } - if (observationsRequest.site != null) { + else if(observationsRequest.person != null && observationsRequest.person.isNotEmpty() && observationsRequest.site != null) { + val person = personRepository.findByName(observationsRequest.person) ?: return listOf() + val site = siteRepository.findById(observationsRequest.site).get() + return observationRepository.findBySiteAndPersonsAndDateBetween(site, person, observationsRequest.startDate, observationsRequest.endDate) + } + else if (observationsRequest.site != null) { return siteRepository.findById(observationsRequest.site).map { when { (observationsRequest.whom == null || observationsRequest.whom.isEmpty()) -> observationRepository.findBySiteAndDateBetween(site = it,