# HG changeset patch # User Mike Becker # Date 1590845175 -7200 # Node ID 1a2e7b5d48f73be84f8266f8b856233b93b3cdc4 # Parent 27a25f32048eca7269dcfe5c2069ac44833da550 adds issue summaries diff -r 27a25f32048e -r 1a2e7b5d48f7 setup/postgres/psql_create_tables.sql --- a/setup/postgres/psql_create_tables.sql Sun May 24 15:30:43 2020 +0200 +++ b/setup/postgres/psql_create_tables.sql Sat May 30 15:26:15 2020 +0200 @@ -41,7 +41,8 @@ 'InReview', 'Done', 'Rejected', - 'Withdrawn' + 'Withdrawn', + 'Duplicate' ); create type issue_category as enum ( @@ -52,6 +53,11 @@ 'Test' ); +create table lpit_issue_phases ( + status issue_status primary key, + phase integer not null +); + create table lpit_issue ( issueid serial primary key, project integer not null references lpit_project(projectid), diff -r 27a25f32048e -r 1a2e7b5d48f7 setup/postgres/psql_default_data.sql --- a/setup/postgres/psql_default_data.sql Sun May 24 15:30:43 2020 +0200 +++ b/setup/postgres/psql_default_data.sql Sat May 30 15:26:15 2020 +0200 @@ -0,0 +1,10 @@ +insert into lpit_issue_phases (status, phase) values + ('InSpecification', 0), + ('ToDo', 0), + ('Scheduled', 1), + ('InProgress', 1), + ('InReview', 1), + ('Done', 2), + ('Rejected', 2), + ('Withdrawn', 2), + ('Duplicate', 2); diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/java/de/uapcore/lightpit/dao/postgres/PGProjectDao.java --- a/src/main/java/de/uapcore/lightpit/dao/postgres/PGProjectDao.java Sun May 24 15:30:43 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/dao/postgres/PGProjectDao.java Sat May 30 15:26:15 2020 +0200 @@ -46,6 +46,7 @@ public final class PGProjectDao implements ProjectDao { private final PreparedStatement insert, update, list, find; + private final PreparedStatement issue_summary; public PGProjectDao(Connection connection) throws SQLException { list = connection.prepareStatement( @@ -62,6 +63,14 @@ "left join lpit_user owner on lpit_project.owner = owner.userid " + "where projectid = ?"); + issue_summary = connection.prepareStatement( + "select phase, count(*) as total "+ + "from lpit_issue " + + "join lpit_issue_phases using(status) " + + "where project = ? "+ + "group by phase " + ); + insert = connection.prepareStatement( "insert into lpit_project (name, description, repourl, owner) values (?, ?, ?, ?)" ); @@ -89,6 +98,26 @@ return proj; } + private void mapIssueSummary(Project proj) throws SQLException { + issue_summary.setInt(1, proj.getId()); + final var result = issue_summary.executeQuery(); + while (result.next()) { + final var phase = result.getInt("phase"); + final var total = result.getInt("total"); + switch(phase) { + case 0: + proj.setOpenIssues(total); + break; + case 1: + proj.setActiveIssues(total); + break; + case 2: + proj.setDoneIssues(total); + break; + } + } + } + @Override public void save(Project instance) throws SQLException { Objects.requireNonNull(instance.getName()); @@ -116,7 +145,9 @@ List projects = new ArrayList<>(); try (var result = list.executeQuery()) { while (result.next()) { - projects.add(mapColumns(result)); + final var project = mapColumns(result); + mapIssueSummary(project); + projects.add(project); } } return projects; @@ -127,7 +158,9 @@ find.setInt(1, id); try (var result = find.executeQuery()) { if (result.next()) { - return mapColumns(result); + final var project = mapColumns(result); + mapIssueSummary(project); + return project; } else { return null; } diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/java/de/uapcore/lightpit/entities/Issue.java --- a/src/main/java/de/uapcore/lightpit/entities/Issue.java Sun May 24 15:30:43 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/entities/Issue.java Sat May 30 15:26:15 2020 +0200 @@ -84,6 +84,10 @@ this.status = status; } + public int getPhase() { + return this.status.getPhase(); + } + public IssueCategory getCategory() { return category; } diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/java/de/uapcore/lightpit/entities/IssueStatus.java --- a/src/main/java/de/uapcore/lightpit/entities/IssueStatus.java Sun May 24 15:30:43 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/entities/IssueStatus.java Sat May 30 15:26:15 2020 +0200 @@ -39,6 +39,10 @@ Withdrawn(2), Duplicate(2); + public static final int PHASE_OPEN = 0; + public static final int PHASE_WIP = 1; + public static final int PHASE_DONE = 2; + private int phase; IssueStatus(int phase) { diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/java/de/uapcore/lightpit/entities/Project.java --- a/src/main/java/de/uapcore/lightpit/entities/Project.java Sun May 24 15:30:43 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/entities/Project.java Sat May 30 15:26:15 2020 +0200 @@ -38,6 +38,10 @@ private String repoUrl; private User owner; + private int openIssues; + private int activeIssues; + private int doneIssues; + public Project(int id) { this.id = id; } @@ -78,6 +82,30 @@ this.owner = owner; } + public int getOpenIssues() { + return openIssues; + } + + public void setOpenIssues(int openIssues) { + this.openIssues = openIssues; + } + + public int getActiveIssues() { + return activeIssues; + } + + public void setActiveIssues(int activeIssues) { + this.activeIssues = activeIssues; + } + + public int getDoneIssues() { + return doneIssues; + } + + public void setDoneIssues(int doneIssues) { + this.doneIssues = doneIssues; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java --- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Sun May 24 15:30:43 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Sat May 30 15:26:15 2020 +0200 @@ -303,6 +303,7 @@ setAttributeHideZeros(req); + req.setAttribute("project", sessionSelection.project); req.setAttribute("versions", versions); req.setAttribute("statsAffected", statsAffected); req.setAttribute("statsScheduled", statsScheduled); @@ -429,9 +430,8 @@ getParameter(req, Date.class, "eta").ifPresent(issue::setEta); dao.getIssueDao().saveOrUpdate(issue); - // TODO: redirect to issue overview // specifying the issue parameter keeps the edited issue as breadcrumb - setRedirectLocation(req, "./projects/view?issue="+issue.getId()); + setRedirectLocation(req, "./projects/issues/?issue="+issue.getId()); setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL); LOG.debug("Successfully updated issue {} for project {}", issue.getId(), sessionSelection.project.getName()); } catch (NoSuchElementException | IllegalArgumentException | SQLException ex) { diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/resources/localization/projects.properties --- a/src/main/resources/localization/projects.properties Sun May 24 15:30:43 2020 +0200 +++ b/src/main/resources/localization/projects.properties Sat May 30 15:26:15 2020 +0200 @@ -39,6 +39,9 @@ thead.description=Description thead.repoUrl=Repository thead.owner=Project Lead +thead.issues.open=Open +thead.issues.active=In Progress +thead.issues.done=Done thead.version.project=Project thead.version.name=Version diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/resources/localization/projects_de.properties --- a/src/main/resources/localization/projects_de.properties Sun May 24 15:30:43 2020 +0200 +++ b/src/main/resources/localization/projects_de.properties Sat May 30 15:26:15 2020 +0200 @@ -39,6 +39,9 @@ thead.description=Beschreibung thead.repoUrl=Repository thead.owner=Projektleitung +thead.issues.open=Offen +thead.issues.active=In Arbeit +thead.issues.done=Erledigt thead.version.project=Projekt thead.version.name=Version diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/webapp/WEB-INF/jsp/issue-form.jsp --- a/src/main/webapp/WEB-INF/jsp/issue-form.jsp Sun May 24 15:30:43 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/issue-form.jsp Sat May 30 15:26:15 2020 +0200 @@ -162,7 +162,7 @@ - ./projects/view?pid=${issue.project.id} + ./projects/issues/?pid=${issue.project.id} ./projects/ diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/webapp/WEB-INF/jsp/issues.jsp --- a/src/main/webapp/WEB-INF/jsp/issues.jsp Sun May 24 15:30:43 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/issues.jsp Sat May 30 15:26:15 2020 +0200 @@ -52,9 +52,11 @@ - - - + + + + + diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/webapp/WEB-INF/jsp/project-details.jsp --- a/src/main/webapp/WEB-INF/jsp/project-details.jsp Sun May 24 15:30:43 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/project-details.jsp Sat May 30 15:26:15 2020 +0200 @@ -28,6 +28,7 @@ <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> + @@ -36,6 +37,28 @@ +
+
+
:
+
+
:
+
+
+
+
:
+
+ +
+
:
+
+ + "> + +
+
+
+
diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/webapp/WEB-INF/jsp/project-form.jsp --- a/src/main/webapp/WEB-INF/jsp/project-form.jsp Sun May 24 15:30:43 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/project-form.jsp Sat May 30 15:26:15 2020 +0200 @@ -43,7 +43,7 @@ " /> - + " /> diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/webapp/WEB-INF/jsp/projects.jsp --- a/src/main/webapp/WEB-INF/jsp/projects.jsp Sun May 24 15:30:43 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/projects.jsp Sat May 30 15:26:15 2020 +0200 @@ -44,21 +44,23 @@
- +
- - - - + + + + + - - + + + @@ -67,17 +69,15 @@ - - + + + diff -r 27a25f32048e -r 1a2e7b5d48f7 src/main/webapp/projects.css --- a/src/main/webapp/projects.css Sun May 24 15:30:43 2020 +0200 +++ b/src/main/webapp/projects.css Sat May 30 15:26:15 2020 +0200 @@ -37,4 +37,29 @@ #version-stats td { text-align: right; -} \ No newline at end of file +} + +#project-attributes { + margin-bottom: 2em; + display: table; +} + +.row { + display: table-row; +} + +.caption { + font-weight: bold; +} + +.row > div { + display: table-cell; +} + +.row > div + div { + padding-left: 2em; +} + +span.phase-2 { + text-decoration: line-through; +}
"> - - - ${project.openIssues}${project.activeIssues}${project.doneIssues}