Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAS-940: Questionnaire Completion Rate Information #288

Merged
4 changes: 2 additions & 2 deletions _infra/helm/case/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 12.0.18
version: 12.0.19

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 12.0.18
appVersion: 12.0.19
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package uk.gov.ons.ctp.response.casesvc.domain.model;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
Expand Down Expand Up @@ -61,4 +62,7 @@ public class CaseGroup implements Serializable {
@Enumerated(EnumType.STRING)
@Column(name = "status")
private CaseGroupStatus status;

@Column(name = "status_change_timestamp")
private Timestamp statusChangeTimestamp;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import uk.gov.ons.ctp.response.casesvc.domain.model.CaseGroup;
import uk.gov.ons.ctp.response.casesvc.domain.model.CaseGroupStatusAudit;
import uk.gov.ons.ctp.response.casesvc.domain.repository.CaseGroupStatusAuditRepository;
import uk.gov.ons.ctp.response.lib.common.time.DateTimeUtil;

@Service
public class CaseGroupAuditService {
Expand All @@ -23,7 +22,7 @@ public void updateAuditTable(final CaseGroup caseGroup, final UUID partyId) {
auditEntity.setCaseGroupFK(caseGroup.getCaseGroupPK());
auditEntity.setStatus(caseGroup.getStatus());
auditEntity.setPartyId(partyId);
auditEntity.setCreatedDateTime(DateTimeUtil.nowUTC());
auditEntity.setCreatedDateTime(caseGroup.getStatusChangeTimestamp());
log.with("audit_entity", auditEntity).debug("Updating the caseGroupStatus");
caseGroupStatusAuditRepository.saveAndFlush(auditEntity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import uk.gov.ons.ctp.response.lib.collection.exercise.CollectionExerciseDTO;
import uk.gov.ons.ctp.response.lib.common.error.CTPException;
import uk.gov.ons.ctp.response.lib.common.state.StateTransitionManager;
import uk.gov.ons.ctp.response.lib.common.time.DateTimeUtil;

/**
* A CaseGroupService implementation which encapsulates all business logic operating on the
Expand Down Expand Up @@ -106,6 +107,7 @@ public void transitionCaseGroupStatus(

if (newCaseGroupStatus != null && !oldCaseGroupStatus.equals(newCaseGroupStatus)) {
caseGroup.setStatus(newCaseGroupStatus);
caseGroup.setStatusChangeTimestamp(DateTimeUtil.nowUTC());
caseGroupRepo.saveAndFlush(caseGroup);
caseGroupAuditService.updateAuditTable(caseGroup, partyId);
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/database/changelog-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,7 @@ databaseChangeLog:
file: database/changes/release-34/changelog.yml

- include:
file: database/changes/release-35/changelog.yml
file: database/changes/release-35/changelog.yml

- include:
file: database/changes/release-36/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE ONLY casesvc.casegroup
ADD status_change_timestamp timestamp with time zone;
11 changes: 11 additions & 0 deletions src/main/resources/database/changes/release-36/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
databaseChangeLog:

- changeSet:
id: 36-1
author: Steve Scorfield
changes:
- sqlFile:
comment: Add a timestamp column for when a status change is made to the survey for a respondent
path: add_timestamp_for_status_change.sql
relativeToChangelogFile: true
splitStatements: false
Loading