548 setIntOrNull(i++, resolved?.id) |
548 setIntOrNull(i++, resolved?.id) |
549 } |
549 } |
550 return i |
550 return i |
551 } |
551 } |
552 |
552 |
|
553 override fun listIssues(includeDone: Boolean): List<Issue> = |
|
554 withStatement("$issueQuery where (? or phase < 2)") { |
|
555 setBoolean(1, includeDone) |
|
556 queryAll { it.extractIssue() } |
|
557 } |
|
558 |
553 override fun listIssues(project: Project, includeDone: Boolean): List<Issue> = |
559 override fun listIssues(project: Project, includeDone: Boolean): List<Issue> = |
554 withStatement("$issueQuery where i.project = ? and (? or phase < 2)") { |
560 withStatement("$issueQuery where i.project = ? and (? or phase < 2)") { |
555 setInt(1, project.id) |
561 setInt(1, project.id) |
556 setBoolean(2, includeDone) |
562 setBoolean(2, includeDone) |
557 queryAll { it.extractIssue() } |
563 queryAll { it.extractIssue() } |
711 queryAll { IssueRelation(issue, findIssue(it.getInt("from_issue"))!!, it.getEnum("type"), true) } |
717 queryAll { IssueRelation(issue, findIssue(it.getInt("from_issue"))!!, it.getEnum("type"), true) } |
712 }.forEach(this::add) |
718 }.forEach(this::add) |
713 } |
719 } |
714 |
720 |
715 override fun getIssueRelationMap(project: Project, includeDone: Boolean): IssueRelationMap = |
721 override fun getIssueRelationMap(project: Project, includeDone: Boolean): IssueRelationMap = |
|
722 getIssueRelationMapImpl(project, includeDone) |
|
723 |
|
724 override fun getIssueRelationMap(includeDone: Boolean): IssueRelationMap = |
|
725 getIssueRelationMapImpl(null, includeDone) |
|
726 |
|
727 private fun getIssueRelationMapImpl(project: Project?, includeDone: Boolean): IssueRelationMap = |
716 withStatement( |
728 withStatement( |
717 """ |
729 """ |
718 select r.from_issue, r.to_issue, r.type |
730 select r.from_issue, r.to_issue, r.type |
719 from lpit_issue_relation r |
731 from lpit_issue_relation r |
720 join lpit_issue i on i.issueid = r.from_issue |
732 join lpit_issue i on i.issueid = r.from_issue |
721 join lpit_issue_phases p on i.status = p.status |
733 join lpit_issue_phases p on i.status = p.status |
722 where i.project = ? and (? or p.phase < 2) |
734 where (? or i.project = ?) and (? or p.phase < 2) |
723 """.trimIndent() |
735 """.trimIndent() |
724 ) { |
736 ) { |
725 setInt(1, project.id) |
737 setBoolean(1, project == null) |
726 setBoolean(2, includeDone) |
738 setInt(2, project?.id ?: 0) |
|
739 setBoolean(3, includeDone) |
727 queryAll { Pair(it.getInt("from_issue"), Pair(it.getInt("to_issue"), it.getEnum<RelationType>("type"))) } |
740 queryAll { Pair(it.getInt("from_issue"), Pair(it.getInt("to_issue"), it.getEnum<RelationType>("type"))) } |
728 }.groupBy({it.first},{it.second}) |
741 }.groupBy({it.first},{it.second}) |
729 //</editor-fold> |
742 //</editor-fold> |
730 |
743 |
731 //<editor-fold desc="IssueComment"> |
744 //<editor-fold desc="IssueComment"> |
802 |
815 |
803 //</editor-fold> |
816 //</editor-fold> |
804 |
817 |
805 //<editor-fold desc="Issue History"> |
818 //<editor-fold desc="Issue History"> |
806 |
819 |
807 override fun listIssueHistory(projectId: Int, days: Int) = |
820 override fun listIssueHistory(project: Project?, days: Int) = |
808 withStatement( |
821 withStatement( |
809 """ |
822 """ |
810 select u.username as current_assignee, evt.*, evtdata.* |
823 select p.name as project_name, u.username as current_assignee, evt.*, evtdata.* |
811 from lpit_issue_history_event evt |
824 from lpit_issue_history_event evt |
812 join lpit_issue issue using (issueid) |
825 join lpit_issue issue using (issueid) |
|
826 join lpit_project p on project = p.projectid |
813 left join lpit_user u on u.userid = issue.assignee |
827 left join lpit_user u on u.userid = issue.assignee |
814 join lpit_issue_history_data evtdata using (eventid) |
828 join lpit_issue_history_data evtdata using (eventid) |
815 where project = ? |
829 where (? or project = ?) |
816 and time > now() - (? * interval '1' day) |
830 and time > now() - (? * interval '1' day) |
817 order by time desc |
831 order by time desc |
818 """.trimIndent() |
832 """.trimIndent() |
819 ) { |
833 ) { |
820 setInt(1, projectId) |
834 setBoolean(1, project == null) |
821 setInt(2, days) |
835 setInt(2, project?.id ?: -1) |
|
836 setInt(3, days) |
822 queryAll { rs-> |
837 queryAll { rs-> |
823 with(rs) { |
838 with(rs) { |
824 IssueHistoryEntry( |
839 IssueHistoryEntry( |
|
840 project = getString("project_name"), |
825 subject = getString("subject"), |
841 subject = getString("subject"), |
826 time = getTimestamp("time"), |
842 time = getTimestamp("time"), |
827 type = getEnum("type"), |
843 type = getEnum("type"), |
828 currentAssignee = getString("current_assignee"), |
844 currentAssignee = getString("current_assignee"), |
829 issueid = getInt("issueid"), |
845 issueid = getInt("issueid"), |
838 ) |
854 ) |
839 } |
855 } |
840 } |
856 } |
841 } |
857 } |
842 |
858 |
843 override fun listIssueCommentHistory(projectId: Int, days: Int) = |
859 override fun listIssueCommentHistory(project: Project?, days: Int) = |
844 withStatement( |
860 withStatement( |
845 """ |
861 """ |
846 select u.username as current_assignee, evt.*, evtdata.* |
862 select u.username as current_assignee, evt.*, evtdata.* |
847 from lpit_issue_history_event evt |
863 from lpit_issue_history_event evt |
848 join lpit_issue issue using (issueid) |
864 join lpit_issue issue using (issueid) |
849 left join lpit_user u on u.userid = issue.assignee |
865 left join lpit_user u on u.userid = issue.assignee |
850 join lpit_issue_comment_history evtdata using (eventid) |
866 join lpit_issue_comment_history evtdata using (eventid) |
851 where project = ? |
867 where (? or project = ?) |
852 and time > now() - (? * interval '1' day) |
868 and time > now() - (? * interval '1' day) |
853 order by time desc |
869 order by time desc |
854 """.trimIndent() |
870 """.trimIndent() |
855 ) { |
871 ) { |
856 setInt(1, projectId) |
872 setBoolean(1, project == null) |
857 setInt(2, days) |
873 setInt(2, project?.id ?: -1) |
|
874 setInt(3, days) |
858 queryAll { rs-> |
875 queryAll { rs-> |
859 with(rs) { |
876 with(rs) { |
860 IssueCommentHistoryEntry( |
877 IssueCommentHistoryEntry( |
861 subject = getString("subject"), |
878 subject = getString("subject"), |
862 time = getTimestamp("time"), |
879 time = getTimestamp("time"), |