src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt

changeset 292
703591e739f4
parent 284
671c1c8fbf1c
child 311
bf67e0ff7131
--- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Mon Oct 30 10:06:22 2023 +0100
+++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Mon Oct 30 14:44:36 2023 +0100
@@ -557,7 +557,14 @@
             queryAll { it.extractIssue() }
         }
 
-    override fun listIssues(project: Project, includeDone: Boolean, version: Version?, component: Component?): List<Issue> =
+    override fun listIssues(
+        project: Project,
+        includeDone: Boolean,
+        specificVersion: Boolean,
+        version: Version?,
+        specificComponent: Boolean,
+        component: Component?
+    ): List<Issue> =
         withStatement(
             """$issueQuery where i.project = ? and
                 (? or phase < 2) and
@@ -565,21 +572,16 @@
                 (not ? or component = ?) and (not ? or component is null)
             """.trimIndent()
         ) {
-            fun <T : Entity> applyFilter(search: T?, fflag: Int, nflag: Int, idcol: Int) {
-                if (search == null) {
-                    setBoolean(fflag, false)
-                    setBoolean(nflag, false)
-                    setInt(idcol, 0)
-                } else {
-                    setBoolean(fflag, true)
-                    setBoolean(nflag, false)
-                    setInt(idcol, search.id)
-                }
-            }
             setInt(1, project.id)
             setBoolean(2, includeDone)
-            applyFilter(version, 3, 5, 4)
-            applyFilter(component, 6, 8, 7)
+
+            setBoolean(3, specificVersion && version != null)
+            setInt(4, version?.id ?: 0)
+            setBoolean(5, specificVersion && version == null)
+
+            setBoolean(6, specificComponent && component != null)
+            setInt(7, component?.id ?: 0)
+            setBoolean(8, specificComponent && component == null)
 
             queryAll { it.extractIssue() }
         }

mercurial