Sat, 27 Nov 2021 10:44:17 +0100
#109 add assignee filter to rss feed
--- a/setup/postgres/psql_create_tables.sql Sun Oct 10 15:12:12 2021 +0200 +++ b/setup/postgres/psql_create_tables.sql Sat Nov 27 10:44:17 2021 +0100 @@ -118,16 +118,17 @@ create table lpit_issue_history_data ( - eventid integer not null references lpit_issue_history_event (eventid) on delete cascade, - component text, - status issue_status not null, - category issue_category not null, - subject text not null, - description text, - assignee text, - eta date, - affected text, - resolved text + eventid integer not null references lpit_issue_history_event (eventid) on delete cascade, + component text, + status issue_status not null, + category issue_category not null, + subject text not null, + description text, + assignee_username text, + assignee text, + eta date, + affected text, + resolved text ); create table lpit_issue_comment
--- a/src/main/kotlin/de/uapcore/lightpit/dao/DataAccessObject.kt Sun Oct 10 15:12:12 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/DataAccessObject.kt Sat Nov 27 10:44:17 2021 +0100 @@ -82,5 +82,8 @@ fun insertHistoryEvent(issue: Issue, newId: Int = 0) fun insertHistoryEvent(issueComment: IssueComment, newId: Int = 0) + /** + * Lists the issue history of the project with [projectId] for the past [days]. + */ fun listIssueHistory(projectId: Int, days: Int): List<IssueHistoryEntry> }
--- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt Sun Oct 10 15:12:12 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt Sat Nov 27 10:44:17 2021 +0100 @@ -604,8 +604,8 @@ } withStatement( """ - insert into lpit_issue_history_data (component, status, category, subject, description, assignee, eta, affected, resolved, eventid) - values (?, ?::issue_status, ?::issue_category, ?, ?, ?, ?, ?, ?, ?) + insert into lpit_issue_history_data (component, status, category, subject, description, assignee, assignee_username, eta, affected, resolved, eventid) + values (?, ?::issue_status, ?::issue_category, ?, ?, ?, ?, ?, ?, ?, ?) """.trimIndent() ) { setStringOrNull(1, issue.component?.name) @@ -614,10 +614,11 @@ setString(4, issue.subject) setStringOrNull(5, issue.description) setStringOrNull(6, issue.assignee?.shortDisplayname) - setDateOrNull(7, issue.eta) - setStringOrNull(8, issue.affected?.name) - setStringOrNull(9, issue.resolved?.name) - setInt(10, eventid) + setStringOrNull(7, issue.assignee?.username) + setDateOrNull(8, issue.eta) + setStringOrNull(9, issue.affected?.name) + setStringOrNull(10, issue.resolved?.name) + setInt(11, eventid) executeUpdate() } } @@ -725,6 +726,7 @@ subject = getString("subject"), description = getString("description") ?: "", assignee = getString("assignee") ?: "", + assigneeUsername = getString("assignee_username") ?: "", eta = getDate("eta"), affected = getString("affected") ?: "", resolved = getString("resolved") ?: ""
--- a/src/main/kotlin/de/uapcore/lightpit/entities/IssueHistoryEntry.kt Sun Oct 10 15:12:12 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/entities/IssueHistoryEntry.kt Sat Nov 27 10:44:17 2021 +0100 @@ -39,6 +39,7 @@ val subject: String, val description: String, val assignee: String, + val assigneeUsername: String, val eta: Date?, val affected: String, val resolved: String,
--- a/src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt Sun Oct 10 15:12:12 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt Sat Nov 27 10:44:17 2021 +0100 @@ -125,10 +125,14 @@ http.response.sendError(404) return } + val assignees = http.param("assignee")?.split(',') val days = http.param("days")?.toIntOrNull() ?: 30 - val issueHistory = dao.listIssueHistory(project.id, days) + val issuesFromDb = dao.listIssueHistory(project.id, days) + val issueHistory = if (assignees == null) issuesFromDb else + issuesFromDb.filter { assignees.contains(it.data.assigneeUsername) } + // TODO: add comment history depending on parameter http.view = IssueFeed(project, generateFeedEntries(issueHistory))