diff -r bbf4eb9a71f8 -r bf67e0ff7131 src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt --- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt Mon Aug 05 17:41:56 2024 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt Mon Aug 05 18:40:47 2024 +0200 @@ -550,6 +550,12 @@ return i } + override fun listIssues(includeDone: Boolean): List = + withStatement("$issueQuery where (? or phase < 2)") { + setBoolean(1, includeDone) + queryAll { it.extractIssue() } + } + override fun listIssues(project: Project, includeDone: Boolean): List = withStatement("$issueQuery where i.project = ? and (? or phase < 2)") { setInt(1, project.id) @@ -713,17 +719,24 @@ } override fun getIssueRelationMap(project: Project, includeDone: Boolean): IssueRelationMap = + getIssueRelationMapImpl(project, includeDone) + + override fun getIssueRelationMap(includeDone: Boolean): IssueRelationMap = + getIssueRelationMapImpl(null, includeDone) + + private fun getIssueRelationMapImpl(project: Project?, includeDone: Boolean): IssueRelationMap = withStatement( """ select r.from_issue, r.to_issue, r.type from lpit_issue_relation r join lpit_issue i on i.issueid = r.from_issue join lpit_issue_phases p on i.status = p.status - where i.project = ? and (? or p.phase < 2) + where (? or i.project = ?) and (? or p.phase < 2) """.trimIndent() ) { - setInt(1, project.id) - setBoolean(2, includeDone) + setBoolean(1, project == null) + setInt(2, project?.id ?: 0) + setBoolean(3, includeDone) queryAll { Pair(it.getInt("from_issue"), Pair(it.getInt("to_issue"), it.getEnum("type"))) } }.groupBy({it.first},{it.second}) // @@ -804,24 +817,27 @@ // - override fun listIssueHistory(projectId: Int, days: Int) = + override fun listIssueHistory(project: Project?, days: Int) = withStatement( """ - select u.username as current_assignee, evt.*, evtdata.* + select p.name as project_name, u.username as current_assignee, evt.*, evtdata.* from lpit_issue_history_event evt join lpit_issue issue using (issueid) + join lpit_project p on project = p.projectid left join lpit_user u on u.userid = issue.assignee join lpit_issue_history_data evtdata using (eventid) - where project = ? + where (? or project = ?) and time > now() - (? * interval '1' day) order by time desc """.trimIndent() ) { - setInt(1, projectId) - setInt(2, days) + setBoolean(1, project == null) + setInt(2, project?.id ?: -1) + setInt(3, days) queryAll { rs-> with(rs) { IssueHistoryEntry( + project = getString("project_name"), subject = getString("subject"), time = getTimestamp("time"), type = getEnum("type"), @@ -840,7 +856,7 @@ } } - override fun listIssueCommentHistory(projectId: Int, days: Int) = + override fun listIssueCommentHistory(project: Project?, days: Int) = withStatement( """ select u.username as current_assignee, evt.*, evtdata.* @@ -848,13 +864,14 @@ 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 = ? + where (? or project = ?) and time > now() - (? * interval '1' day) order by time desc """.trimIndent() ) { - setInt(1, projectId) - setInt(2, days) + setBoolean(1, project == null) + setInt(2, project?.id ?: -1) + setInt(3, days) queryAll { rs-> with(rs) { IssueCommentHistoryEntry(