#109 changes assignee filter

Sat, 27 Nov 2021 12:12:20 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 27 Nov 2021 12:12:20 +0100
changeset 241
1ca4f27cefe8
parent 240
7303812a4424
child 242
b7f3e972b13c

#109 changes assignee filter

setup/postgres/psql_create_tables.sql file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/dao/DataAccessObject.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/entities/IssueHistoryEntry.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt file | annotate | diff | comparison | revisions
     1.1 --- a/setup/postgres/psql_create_tables.sql	Sat Nov 27 11:04:23 2021 +0100
     1.2 +++ b/setup/postgres/psql_create_tables.sql	Sat Nov 27 12:12:20 2021 +0100
     1.3 @@ -124,7 +124,6 @@
     1.4      category          issue_category not null,
     1.5      subject           text           not null,
     1.6      description       text,
     1.7 -    assignee_username text,
     1.8      assignee          text,
     1.9      eta               date,
    1.10      affected          text,
     2.1 --- a/src/main/kotlin/de/uapcore/lightpit/dao/DataAccessObject.kt	Sat Nov 27 11:04:23 2021 +0100
     2.2 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/DataAccessObject.kt	Sat Nov 27 12:12:20 2021 +0100
     2.3 @@ -86,4 +86,9 @@
     2.4       * Lists the issue history of the project with [projectId] for the past [days].
     2.5       */
     2.6      fun listIssueHistory(projectId: Int, days: Int): List<IssueHistoryEntry>
     2.7 +
     2.8 +    /**
     2.9 +     * Lists the issue comment history of the project with [projectId] for the past [days].
    2.10 +     */
    2.11 +    fun listIssueCommentHistory(projectId: Int, days: Int): List<IssueCommentHistoryEntry>
    2.12  }
     3.1 --- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Sat Nov 27 11:04:23 2021 +0100
     3.2 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Sat Nov 27 12:12:20 2021 +0100
     3.3 @@ -703,9 +703,10 @@
     3.4      override fun listIssueHistory(projectId: Int, days: Int) =
     3.5          withStatement(
     3.6              """
     3.7 -                select evt.*, evtdata.*
     3.8 +                select u.username as current_assignee, evt.*, evtdata.*
     3.9                  from lpit_issue_history_event evt
    3.10 -                join lpit_issue using (issueid)
    3.11 +                join lpit_issue issue using (issueid)
    3.12 +                left join lpit_user u on u.userid = issue.assignee
    3.13                  join lpit_issue_history_data evtdata using (eventid)
    3.14                  where project = ?
    3.15                  and time > now() - (? * interval '1' day) 
    3.16 @@ -719,6 +720,7 @@
    3.17                      IssueHistoryEntry(
    3.18                          getTimestamp("time"),
    3.19                          getEnum("type"),
    3.20 +                        getString("current_assignee"),
    3.21                          IssueHistoryData(getInt("issueid"),
    3.22                              component = getString("component") ?: "",
    3.23                              status = getEnum("status"),
    3.24 @@ -726,7 +728,6 @@
    3.25                              subject = getString("subject"),
    3.26                              description = getString("description") ?: "",
    3.27                              assignee = getString("assignee") ?: "",
    3.28 -                            assigneeUsername = getString("assignee_username") ?: "",
    3.29                              eta = getDate("eta"),
    3.30                              affected = getString("affected") ?: "",
    3.31                              resolved = getString("resolved") ?: ""
    3.32 @@ -736,5 +737,35 @@
    3.33              }
    3.34          }
    3.35  
    3.36 +    override fun listIssueCommentHistory(projectId: Int, days: Int) =
    3.37 +        withStatement(
    3.38 +            """
    3.39 +                select u.username as current_assignee, evt.*, evtdata.*
    3.40 +                from lpit_issue_history_event evt
    3.41 +                join lpit_issue issue using (issueid)
    3.42 +                left join lpit_user u on u.userid = issue.assignee
    3.43 +                join lpit_issue_comment_history evtdata using (eventid)
    3.44 +                where project = ?
    3.45 +                and time > now() - (? * interval '1' day) 
    3.46 +                order by time desc
    3.47 +            """.trimIndent()
    3.48 +        ) {
    3.49 +            setInt(1, projectId)
    3.50 +            setInt(2, days)
    3.51 +            queryAll { rs->
    3.52 +                with(rs) {
    3.53 +                    IssueCommentHistoryEntry(
    3.54 +                        getTimestamp("time"),
    3.55 +                        getEnum("type"),
    3.56 +                        getString("current_assignee"),
    3.57 +                        IssueCommentHistoryData(
    3.58 +                            getInt("commentid"),
    3.59 +                            getString("comment")
    3.60 +                        )
    3.61 +                    )
    3.62 +                }
    3.63 +            }
    3.64 +        }
    3.65 +
    3.66      //</editor-fold>
    3.67  }
    3.68 \ No newline at end of file
     4.1 --- a/src/main/kotlin/de/uapcore/lightpit/entities/IssueHistoryEntry.kt	Sat Nov 27 11:04:23 2021 +0100
     4.2 +++ b/src/main/kotlin/de/uapcore/lightpit/entities/IssueHistoryEntry.kt	Sat Nov 27 12:12:20 2021 +0100
     4.3 @@ -39,10 +39,26 @@
     4.4      val subject: String,
     4.5      val description: String,
     4.6      val assignee: String,
     4.7 -    val assigneeUsername: String,
     4.8      val eta: Date?,
     4.9      val affected: String,
    4.10      val resolved: String,
    4.11  )
    4.12  
    4.13 -class IssueHistoryEntry(val time: Timestamp, val type: IssueHistoryType, val data: IssueHistoryData)
    4.14 \ No newline at end of file
    4.15 +class IssueCommentHistoryData(
    4.16 +    val commentid: Int,
    4.17 +    val comment: String
    4.18 +)
    4.19 +
    4.20 +class IssueHistoryEntry(
    4.21 +    val time: Timestamp,
    4.22 +    val type: IssueHistoryType,
    4.23 +    val currentAssignee: String?,
    4.24 +    val data: IssueHistoryData
    4.25 +)
    4.26 +
    4.27 +class IssueCommentHistoryEntry(
    4.28 +    val time: Timestamp,
    4.29 +    val type: IssueHistoryType,
    4.30 +    val currentAssignee: String?,
    4.31 +    val data: IssueCommentHistoryData
    4.32 +)
    4.33 \ No newline at end of file
     5.1 --- a/src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt	Sat Nov 27 11:04:23 2021 +0100
     5.2 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt	Sat Nov 27 12:12:20 2021 +0100
     5.3 @@ -131,7 +131,7 @@
     5.4  
     5.5          val issuesFromDb = dao.listIssueHistory(project.id, days)
     5.6          val issueHistory = if (assignees == null) issuesFromDb else
     5.7 -            issuesFromDb.filter { assignees.contains(it.data.assigneeUsername) }
     5.8 +            issuesFromDb.filter { assignees.contains(it.currentAssignee) }
     5.9  
    5.10          // TODO: add comment history depending on parameter
    5.11  

mercurial