From ed1e7546a77a4c34639654bc48bd0755e1000057 Mon Sep 17 00:00:00 2001 From: gowthaman Date: Thu, 16 May 2024 17:30:19 +0530 Subject: [PATCH] add an all plant filter --- src/main/kotlin/com/restapi/controllers/Filters.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/restapi/controllers/Filters.kt b/src/main/kotlin/com/restapi/controllers/Filters.kt index 1f19415..66d18ca 100644 --- a/src/main/kotlin/com/restapi/controllers/Filters.kt +++ b/src/main/kotlin/com/restapi/controllers/Filters.kt @@ -118,10 +118,11 @@ fun applyVendorHelper(q: io.ebean.ExpressionList, vids: List?) { fun applyPlantFilter(q: io.ebean.ExpressionList, vids: List?) { - if (vids.isNullOrEmpty()) { + val v = vids?.filter { it > 0 } ?: emptyList() + if (v.isEmpty()) { q.`in`("unloadingPlantId", Session.currentUserPlants().map { it.plantId }) } else { - q.`in`("unloadingPlantId", vids.map { it.toString() }) + q.`in`("unloadingPlantId", v.map { it.toString() }) } }