Sat, 27 Nov 2021 10:44:17 +0100
#109 add assignee filter to rss feed
1.1 --- a/setup/postgres/psql_create_tables.sql Sun Oct 10 15:12:12 2021 +0200 1.2 +++ b/setup/postgres/psql_create_tables.sql Sat Nov 27 10:44:17 2021 +0100 1.3 @@ -118,16 +118,17 @@ 1.4 1.5 create table lpit_issue_history_data 1.6 ( 1.7 - eventid integer not null references lpit_issue_history_event (eventid) on delete cascade, 1.8 - component text, 1.9 - status issue_status not null, 1.10 - category issue_category not null, 1.11 - subject text not null, 1.12 - description text, 1.13 - assignee text, 1.14 - eta date, 1.15 - affected text, 1.16 - resolved text 1.17 + eventid integer not null references lpit_issue_history_event (eventid) on delete cascade, 1.18 + component text, 1.19 + status issue_status not null, 1.20 + category issue_category not null, 1.21 + subject text not null, 1.22 + description text, 1.23 + assignee_username text, 1.24 + assignee text, 1.25 + eta date, 1.26 + affected text, 1.27 + resolved text 1.28 ); 1.29 1.30 create table lpit_issue_comment
2.1 --- a/src/main/kotlin/de/uapcore/lightpit/dao/DataAccessObject.kt Sun Oct 10 15:12:12 2021 +0200 2.2 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/DataAccessObject.kt Sat Nov 27 10:44:17 2021 +0100 2.3 @@ -82,5 +82,8 @@ 2.4 fun insertHistoryEvent(issue: Issue, newId: Int = 0) 2.5 fun insertHistoryEvent(issueComment: IssueComment, newId: Int = 0) 2.6 2.7 + /** 2.8 + * Lists the issue history of the project with [projectId] for the past [days]. 2.9 + */ 2.10 fun listIssueHistory(projectId: Int, days: Int): List<IssueHistoryEntry> 2.11 }
3.1 --- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt Sun Oct 10 15:12:12 2021 +0200 3.2 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt Sat Nov 27 10:44:17 2021 +0100 3.3 @@ -604,8 +604,8 @@ 3.4 } 3.5 withStatement( 3.6 """ 3.7 - insert into lpit_issue_history_data (component, status, category, subject, description, assignee, eta, affected, resolved, eventid) 3.8 - values (?, ?::issue_status, ?::issue_category, ?, ?, ?, ?, ?, ?, ?) 3.9 + insert into lpit_issue_history_data (component, status, category, subject, description, assignee, assignee_username, eta, affected, resolved, eventid) 3.10 + values (?, ?::issue_status, ?::issue_category, ?, ?, ?, ?, ?, ?, ?, ?) 3.11 """.trimIndent() 3.12 ) { 3.13 setStringOrNull(1, issue.component?.name) 3.14 @@ -614,10 +614,11 @@ 3.15 setString(4, issue.subject) 3.16 setStringOrNull(5, issue.description) 3.17 setStringOrNull(6, issue.assignee?.shortDisplayname) 3.18 - setDateOrNull(7, issue.eta) 3.19 - setStringOrNull(8, issue.affected?.name) 3.20 - setStringOrNull(9, issue.resolved?.name) 3.21 - setInt(10, eventid) 3.22 + setStringOrNull(7, issue.assignee?.username) 3.23 + setDateOrNull(8, issue.eta) 3.24 + setStringOrNull(9, issue.affected?.name) 3.25 + setStringOrNull(10, issue.resolved?.name) 3.26 + setInt(11, eventid) 3.27 executeUpdate() 3.28 } 3.29 } 3.30 @@ -725,6 +726,7 @@ 3.31 subject = getString("subject"), 3.32 description = getString("description") ?: "", 3.33 assignee = getString("assignee") ?: "", 3.34 + assigneeUsername = getString("assignee_username") ?: "", 3.35 eta = getDate("eta"), 3.36 affected = getString("affected") ?: "", 3.37 resolved = getString("resolved") ?: ""
4.1 --- a/src/main/kotlin/de/uapcore/lightpit/entities/IssueHistoryEntry.kt Sun Oct 10 15:12:12 2021 +0200 4.2 +++ b/src/main/kotlin/de/uapcore/lightpit/entities/IssueHistoryEntry.kt Sat Nov 27 10:44:17 2021 +0100 4.3 @@ -39,6 +39,7 @@ 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,
5.1 --- a/src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt Sun Oct 10 15:12:12 2021 +0200 5.2 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt Sat Nov 27 10:44:17 2021 +0100 5.3 @@ -125,10 +125,14 @@ 5.4 http.response.sendError(404) 5.5 return 5.6 } 5.7 + val assignees = http.param("assignee")?.split(',') 5.8 5.9 val days = http.param("days")?.toIntOrNull() ?: 30 5.10 5.11 - val issueHistory = dao.listIssueHistory(project.id, days) 5.12 + val issuesFromDb = dao.listIssueHistory(project.id, days) 5.13 + val issueHistory = if (assignees == null) issuesFromDb else 5.14 + issuesFromDb.filter { assignees.contains(it.data.assigneeUsername) } 5.15 + 5.16 // TODO: add comment history depending on parameter 5.17 5.18 http.view = IssueFeed(project, generateFeedEntries(issueHistory))