src/main/java/de/uapcore/lightpit/dao/postgres/PGProjectDao.java

changeset 86
0a658e53177c
parent 81
1a2e7b5d48f7
child 128
947d0f6a6a83
     1.1 --- a/src/main/java/de/uapcore/lightpit/dao/postgres/PGProjectDao.java	Sat May 30 18:12:38 2020 +0200
     1.2 +++ b/src/main/java/de/uapcore/lightpit/dao/postgres/PGProjectDao.java	Mon Jun 01 14:46:58 2020 +0200
     1.3 @@ -29,6 +29,7 @@
     1.4  package de.uapcore.lightpit.dao.postgres;
     1.5  
     1.6  import de.uapcore.lightpit.dao.ProjectDao;
     1.7 +import de.uapcore.lightpit.entities.IssueSummary;
     1.8  import de.uapcore.lightpit.entities.Project;
     1.9  import de.uapcore.lightpit.entities.User;
    1.10  
    1.11 @@ -98,24 +99,26 @@
    1.12          return proj;
    1.13      }
    1.14  
    1.15 -    private void mapIssueSummary(Project proj) throws SQLException {
    1.16 -        issue_summary.setInt(1, proj.getId());
    1.17 +    public IssueSummary getIssueSummary(Project project) throws SQLException {
    1.18 +        issue_summary.setInt(1, project.getId());
    1.19          final var result = issue_summary.executeQuery();
    1.20 +        final var summary = new IssueSummary();
    1.21          while (result.next()) {
    1.22              final var phase = result.getInt("phase");
    1.23              final var total = result.getInt("total");
    1.24              switch(phase) {
    1.25                  case 0:
    1.26 -                    proj.setOpenIssues(total);
    1.27 +                    summary.setOpen(total);
    1.28                      break;
    1.29                  case 1:
    1.30 -                    proj.setActiveIssues(total);
    1.31 +                    summary.setActive(total);
    1.32                      break;
    1.33                  case 2:
    1.34 -                    proj.setDoneIssues(total);
    1.35 +                    summary.setDone(total);
    1.36                      break;
    1.37              }
    1.38          }
    1.39 +        return summary;
    1.40      }
    1.41  
    1.42      @Override
    1.43 @@ -146,7 +149,6 @@
    1.44          try (var result = list.executeQuery()) {
    1.45              while (result.next()) {
    1.46                  final var project = mapColumns(result);
    1.47 -                mapIssueSummary(project);
    1.48                  projects.add(project);
    1.49              }
    1.50          }
    1.51 @@ -159,7 +161,6 @@
    1.52          try (var result = find.executeQuery()) {
    1.53              if (result.next()) {
    1.54                  final var project = mapColumns(result);
    1.55 -                mapIssueSummary(project);
    1.56                  return project;
    1.57              } else {
    1.58                  return null;

mercurial