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

changeset 241
1ca4f27cefe8
parent 239
9365c7fb0240
child 242
b7f3e972b13c
     1.1 --- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Sat Nov 27 11:04:23 2021 +0100
     1.2 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Sat Nov 27 12:12:20 2021 +0100
     1.3 @@ -703,9 +703,10 @@
     1.4      override fun listIssueHistory(projectId: Int, days: Int) =
     1.5          withStatement(
     1.6              """
     1.7 -                select evt.*, evtdata.*
     1.8 +                select u.username as current_assignee, evt.*, evtdata.*
     1.9                  from lpit_issue_history_event evt
    1.10 -                join lpit_issue using (issueid)
    1.11 +                join lpit_issue issue using (issueid)
    1.12 +                left join lpit_user u on u.userid = issue.assignee
    1.13                  join lpit_issue_history_data evtdata using (eventid)
    1.14                  where project = ?
    1.15                  and time > now() - (? * interval '1' day) 
    1.16 @@ -719,6 +720,7 @@
    1.17                      IssueHistoryEntry(
    1.18                          getTimestamp("time"),
    1.19                          getEnum("type"),
    1.20 +                        getString("current_assignee"),
    1.21                          IssueHistoryData(getInt("issueid"),
    1.22                              component = getString("component") ?: "",
    1.23                              status = getEnum("status"),
    1.24 @@ -726,7 +728,6 @@
    1.25                              subject = getString("subject"),
    1.26                              description = getString("description") ?: "",
    1.27                              assignee = getString("assignee") ?: "",
    1.28 -                            assigneeUsername = getString("assignee_username") ?: "",
    1.29                              eta = getDate("eta"),
    1.30                              affected = getString("affected") ?: "",
    1.31                              resolved = getString("resolved") ?: ""
    1.32 @@ -736,5 +737,35 @@
    1.33              }
    1.34          }
    1.35  
    1.36 +    override fun listIssueCommentHistory(projectId: Int, days: Int) =
    1.37 +        withStatement(
    1.38 +            """
    1.39 +                select u.username as current_assignee, evt.*, evtdata.*
    1.40 +                from lpit_issue_history_event evt
    1.41 +                join lpit_issue issue using (issueid)
    1.42 +                left join lpit_user u on u.userid = issue.assignee
    1.43 +                join lpit_issue_comment_history evtdata using (eventid)
    1.44 +                where project = ?
    1.45 +                and time > now() - (? * interval '1' day) 
    1.46 +                order by time desc
    1.47 +            """.trimIndent()
    1.48 +        ) {
    1.49 +            setInt(1, projectId)
    1.50 +            setInt(2, days)
    1.51 +            queryAll { rs->
    1.52 +                with(rs) {
    1.53 +                    IssueCommentHistoryEntry(
    1.54 +                        getTimestamp("time"),
    1.55 +                        getEnum("type"),
    1.56 +                        getString("current_assignee"),
    1.57 +                        IssueCommentHistoryData(
    1.58 +                            getInt("commentid"),
    1.59 +                            getString("comment")
    1.60 +                        )
    1.61 +                    )
    1.62 +                }
    1.63 +            }
    1.64 +        }
    1.65 +
    1.66      //</editor-fold>
    1.67  }
    1.68 \ No newline at end of file

mercurial