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

changeset 257
c1be672af7ff
parent 248
90dc13c78b5d
child 260
fb2ae2d63a56
--- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Thu Dec 29 14:03:00 2022 +0100
+++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Thu Dec 29 14:50:35 2022 +0100
@@ -444,6 +444,32 @@
             }
         }
 
+    override fun collectIssueSummary(assignee: User): IssueSummary =
+        withStatement(
+            """
+            select phase, count(*) as total
+            from lpit_issue
+            join lpit_issue_phases using(status)
+            where assignee = ?
+            group by phase  
+            """.trimIndent()
+        ) {
+            setInt(1, assignee.id)
+            executeQuery().use {
+                val summary = IssueSummary()
+                while (it.next()) {
+                    val phase = it.getInt("phase")
+                    val total = it.getInt("total")
+                    when (phase) {
+                        0 -> summary.open = total
+                        1 -> summary.active = total
+                        2 -> summary.done = total
+                    }
+                }
+                summary
+            }
+        }
+
     //</editor-fold>
 
     //<editor-fold desc="Issue">

mercurial