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

changeset 241
1ca4f27cefe8
parent 239
9365c7fb0240
child 242
b7f3e972b13c
--- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Sat Nov 27 11:04:23 2021 +0100
+++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Sat Nov 27 12:12:20 2021 +0100
@@ -703,9 +703,10 @@
     override fun listIssueHistory(projectId: Int, days: Int) =
         withStatement(
             """
-                select evt.*, evtdata.*
+                select u.username as current_assignee, evt.*, evtdata.*
                 from lpit_issue_history_event evt
-                join lpit_issue using (issueid)
+                join lpit_issue issue using (issueid)
+                left join lpit_user u on u.userid = issue.assignee
                 join lpit_issue_history_data evtdata using (eventid)
                 where project = ?
                 and time > now() - (? * interval '1' day) 
@@ -719,6 +720,7 @@
                     IssueHistoryEntry(
                         getTimestamp("time"),
                         getEnum("type"),
+                        getString("current_assignee"),
                         IssueHistoryData(getInt("issueid"),
                             component = getString("component") ?: "",
                             status = getEnum("status"),
@@ -726,7 +728,6 @@
                             subject = getString("subject"),
                             description = getString("description") ?: "",
                             assignee = getString("assignee") ?: "",
-                            assigneeUsername = getString("assignee_username") ?: "",
                             eta = getDate("eta"),
                             affected = getString("affected") ?: "",
                             resolved = getString("resolved") ?: ""
@@ -736,5 +737,35 @@
             }
         }
 
+    override fun listIssueCommentHistory(projectId: Int, days: Int) =
+        withStatement(
+            """
+                select u.username as current_assignee, evt.*, evtdata.*
+                from lpit_issue_history_event evt
+                join lpit_issue issue using (issueid)
+                left join lpit_user u on u.userid = issue.assignee
+                join lpit_issue_comment_history evtdata using (eventid)
+                where project = ?
+                and time > now() - (? * interval '1' day) 
+                order by time desc
+            """.trimIndent()
+        ) {
+            setInt(1, projectId)
+            setInt(2, days)
+            queryAll { rs->
+                with(rs) {
+                    IssueCommentHistoryEntry(
+                        getTimestamp("time"),
+                        getEnum("type"),
+                        getString("current_assignee"),
+                        IssueCommentHistoryData(
+                            getInt("commentid"),
+                            getString("comment")
+                        )
+                    )
+                }
+            }
+        }
+
     //</editor-fold>
 }
\ No newline at end of file

mercurial