1.1 --- a/src/main/java/de/uapcore/lightpit/dao/postgres/PGVersionDao.java Sat May 30 18:12:38 2020 +0200 1.2 +++ b/src/main/java/de/uapcore/lightpit/dao/postgres/PGVersionDao.java Mon Jun 01 14:46:58 2020 +0200 1.3 @@ -29,7 +29,9 @@ 1.4 package de.uapcore.lightpit.dao.postgres; 1.5 1.6 import de.uapcore.lightpit.dao.VersionDao; 1.7 -import de.uapcore.lightpit.entities.*; 1.8 +import de.uapcore.lightpit.entities.Project; 1.9 +import de.uapcore.lightpit.entities.Version; 1.10 +import de.uapcore.lightpit.entities.VersionStatus; 1.11 1.12 import java.sql.Connection; 1.13 import java.sql.PreparedStatement; 1.14 @@ -42,7 +44,6 @@ 1.15 public final class PGVersionDao implements VersionDao { 1.16 1.17 private final PreparedStatement insert, update, list, find; 1.18 - private final PreparedStatement issuesAffected, issuesScheduled, issuesResolved; 1.19 1.20 public PGVersionDao(Connection connection) throws SQLException { 1.21 list = connection.prepareStatement( 1.22 @@ -64,54 +65,19 @@ 1.23 update = connection.prepareStatement( 1.24 "update lpit_version set name = ?, ordinal = ?, status = ?::version_status where versionid = ?" 1.25 ); 1.26 - 1.27 - issuesAffected = connection.prepareStatement( 1.28 - "select category, status, count(*) as issuecount " + 1.29 - "from lpit_issue_affected_version " + 1.30 - "join lpit_issue using (issueid) " + 1.31 - "where versionid = ? " + 1.32 - "group by category, status" 1.33 - ); 1.34 - issuesScheduled = connection.prepareStatement( 1.35 - "select category, status, count(*) as issuecount " + 1.36 - "from lpit_issue_scheduled_version " + 1.37 - "join lpit_issue using (issueid) " + 1.38 - "where versionid = ? " + 1.39 - "group by category, status" 1.40 - ); 1.41 - issuesResolved = connection.prepareStatement( 1.42 - "select category, status, count(*) as issuecount " + 1.43 - "from lpit_issue_resolved_version " + 1.44 - "join lpit_issue using (issueid) " + 1.45 - "where versionid = ? " + 1.46 - "group by category, status" 1.47 - ); 1.48 } 1.49 1.50 private Version mapColumns(ResultSet result) throws SQLException { 1.51 final var project = new Project(result.getInt("project")); 1.52 project.setName(result.getString("projectname")); 1.53 - final var version = new Version(result.getInt("versionid"), project); 1.54 + final var version = new Version(result.getInt("versionid")); 1.55 + version.setProject(project); 1.56 version.setName(result.getString("name")); 1.57 version.setOrdinal(result.getInt("ordinal")); 1.58 version.setStatus(VersionStatus.valueOf(result.getString("status"))); 1.59 return version; 1.60 } 1.61 1.62 - private VersionStatistics versionStatistics(Version version, PreparedStatement stmt) throws SQLException { 1.63 - stmt.setInt(1, version.getId()); 1.64 - final var result = stmt.executeQuery(); 1.65 - final var stats = new VersionStatistics(version); 1.66 - while (result.next()) { 1.67 - stats.setIssueCount( 1.68 - IssueCategory.valueOf(result.getString("category")), 1.69 - IssueStatus.valueOf(result.getString("status")), 1.70 - result.getInt("issuecount") 1.71 - ); 1.72 - } 1.73 - return stats; 1.74 - } 1.75 - 1.76 @Override 1.77 public void save(Version instance) throws SQLException { 1.78 Objects.requireNonNull(instance.getName()); 1.79 @@ -159,19 +125,4 @@ 1.80 } 1.81 } 1.82 } 1.83 - 1.84 - @Override 1.85 - public VersionStatistics statsOpenedIssues(Version version) throws SQLException { 1.86 - return versionStatistics(version, issuesAffected); 1.87 - } 1.88 - 1.89 - @Override 1.90 - public VersionStatistics statsScheduledIssues(Version version) throws SQLException { 1.91 - return versionStatistics(version, issuesScheduled); 1.92 - } 1.93 - 1.94 - @Override 1.95 - public VersionStatistics statsResolvedIssues(Version version) throws SQLException { 1.96 - return versionStatistics(version, issuesResolved); 1.97 - } 1.98 }