Sat, 27 Nov 2021 12:12:20 +0100
#109 changes assignee filter
--- a/setup/postgres/psql_create_tables.sql Sat Nov 27 11:04:23 2021 +0100 +++ b/setup/postgres/psql_create_tables.sql Sat Nov 27 12:12:20 2021 +0100 @@ -124,7 +124,6 @@ category issue_category not null, subject text not null, description text, - assignee_username text, assignee text, eta date, affected text,
--- a/src/main/kotlin/de/uapcore/lightpit/dao/DataAccessObject.kt Sat Nov 27 11:04:23 2021 +0100 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/DataAccessObject.kt Sat Nov 27 12:12:20 2021 +0100 @@ -86,4 +86,9 @@ * Lists the issue history of the project with [projectId] for the past [days]. */ fun listIssueHistory(projectId: Int, days: Int): List<IssueHistoryEntry> + + /** + * Lists the issue comment history of the project with [projectId] for the past [days]. + */ + fun listIssueCommentHistory(projectId: Int, days: Int): List<IssueCommentHistoryEntry> }
--- 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
--- a/src/main/kotlin/de/uapcore/lightpit/entities/IssueHistoryEntry.kt Sat Nov 27 11:04:23 2021 +0100 +++ b/src/main/kotlin/de/uapcore/lightpit/entities/IssueHistoryEntry.kt Sat Nov 27 12:12:20 2021 +0100 @@ -39,10 +39,26 @@ val subject: String, val description: String, val assignee: String, - val assigneeUsername: String, val eta: Date?, val affected: String, val resolved: String, ) -class IssueHistoryEntry(val time: Timestamp, val type: IssueHistoryType, val data: IssueHistoryData) \ No newline at end of file +class IssueCommentHistoryData( + val commentid: Int, + val comment: String +) + +class IssueHistoryEntry( + val time: Timestamp, + val type: IssueHistoryType, + val currentAssignee: String?, + val data: IssueHistoryData +) + +class IssueCommentHistoryEntry( + val time: Timestamp, + val type: IssueHistoryType, + val currentAssignee: String?, + val data: IssueCommentHistoryData +) \ No newline at end of file
--- a/src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt Sat Nov 27 11:04:23 2021 +0100 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt Sat Nov 27 12:12:20 2021 +0100 @@ -131,7 +131,7 @@ val issuesFromDb = dao.listIssueHistory(project.id, days) val issueHistory = if (assignees == null) issuesFromDb else - issuesFromDb.filter { assignees.contains(it.data.assigneeUsername) } + issuesFromDb.filter { assignees.contains(it.currentAssignee) } // TODO: add comment history depending on parameter