Skip to content

Commit

Permalink
avniproject/avni-client#1172 | Introduce new fields in RuleFailureTel…
Browse files Browse the repository at this point in the history
…emetry
  • Loading branch information
himeshr committed Nov 15, 2023
1 parent 1e5d4f2 commit f18d663
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.avni.server.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.avni.server.domain.enums.ruleFailure.AppType;
import org.avni.server.domain.enums.ruleFailure.EntityType;
import org.avni.server.domain.enums.ruleFailure.SourceType;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
Expand Down Expand Up @@ -36,6 +39,24 @@ public class RuleFailureTelemetry {
@Column
private String ruleUuid;

@Column
@Enumerated(EnumType.STRING)
private SourceType sourceType;

@Column
private String sourceId;

@Column
@Enumerated(EnumType.STRING)
private EntityType entityType;

@Column
private String entityId;

@Column
@Enumerated(EnumType.STRING)
private AppType appType;

@Column
private String individualUuid;

Expand All @@ -46,13 +67,14 @@ public class RuleFailureTelemetry {
private String stacktrace;

@Column
private DateTime closeDateTime;
private DateTime closedDateTime;

@Column
private DateTime errorDateTime;

@Column
private Boolean isClosed;

@Column
private Long organisationId;

Expand Down Expand Up @@ -157,6 +179,46 @@ public void setRuleUuid(String ruleUuid) {
this.ruleUuid = ruleUuid;
}

public SourceType getSourceType() {
return sourceType;
}

public void setSourceType(SourceType sourceType) {
this.sourceType = sourceType;
}

public String getSourceId() {
return sourceId;
}

public void setSourceId(String sourceId) {
this.sourceId = sourceId;
}

public EntityType getEntityType() {
return entityType;
}

public void setEntityType(EntityType entityType) {
this.entityType = entityType;
}

public String getEntityId() {
return entityId;
}

public void setEntityId(String entityId) {
this.entityId = entityId;
}

public AppType getAppType() {
return appType;
}

public void setAppType(AppType appType) {
this.appType = appType;
}

public String getIndividualUuid() {
return individualUuid;
}
Expand All @@ -181,12 +243,12 @@ public void setStacktrace(String stacktrace) {
this.stacktrace = stacktrace;
}

public DateTime getCloseDateTime() {
return closeDateTime;
public DateTime getClosedDateTime() {
return closedDateTime;
}

public void setCloseDateTime(DateTime closeDateTime) {
this.closeDateTime = closeDateTime;
public void setClosedDateTime(DateTime closedDateTime) {
this.closedDateTime = closedDateTime;
}

public DateTime getErrorDateTime() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.avni.server.domain.enums.ruleFailure;

public enum AppType {
Android, Web
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.avni.server.domain.enums.ruleFailure;

public enum EntityType {
Individual, ProgramEnrolment, ProgramEncounter, Encounter, WorkList, Checklist, ReportCard;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.avni.server.domain.enums.ruleFailure;

public enum SourceType {
Decision, VisitSchedule, Validation, EnrolmentSummary, SubjectSummary, WorkListUpdation, ManualEnrolmentEligibilityCheckRule, EnrolmentEligibilityCheck, EncounterEligibilityCheck, Checklist, FormElement, FormElementGroup, OldRule, ReportCard
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public void save(@RequestBody RuleFailureTelemetryRequest request) {
ruleFailureTelemetry.setStacktrace(request.getStacktrace());
ruleFailureTelemetry.setRuleUuid(request.getRuleUuid());
ruleFailureTelemetry.setErrorDateTime(request.getErrorDateTime());
ruleFailureTelemetry.setSourceType(request.getSourceType());
ruleFailureTelemetry.setSourceId(request.getSourceId());
ruleFailureTelemetry.setEntityType(request.getEntityType());
ruleFailureTelemetry.setEntityId(request.getEntityId());
ruleFailureTelemetry.setAppType(request.getAppType());
ruleFailureTelemetry.setClosed(request.getClosed());
ruleFailureTelemetryRepository.save(ruleFailureTelemetry);
}
Expand All @@ -85,7 +90,7 @@ public ResponseEntity<List<RuleFailureTelemetry>> updateStatus(@RequestParam("id
List<RuleFailureTelemetry> ruleFailureTelemetries = ruleFailureTelemetryRepository.findAllById(ids);
ruleFailureTelemetries.forEach(ruleFailureTelemetry -> {
ruleFailureTelemetry.setClosed(isClosed);
ruleFailureTelemetry.setCloseDateTime(isClosed ? DateTime.now() : null);
ruleFailureTelemetry.setClosedDateTime(isClosed ? DateTime.now() : null);
});
ruleFailureTelemetryRepository.saveAll(ruleFailureTelemetries);
return new ResponseEntity<>(ruleFailureTelemetries, HttpStatus.CREATED);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.avni.server.web.request;

import org.avni.server.domain.enums.ruleFailure.AppType;
import org.avni.server.domain.enums.ruleFailure.EntityType;
import org.avni.server.domain.enums.ruleFailure.SourceType;
import org.joda.time.DateTime;

public class RuleFailureTelemetryRequest {
Expand All @@ -8,6 +11,11 @@ public class RuleFailureTelemetryRequest {
private String individualUuid;
private String ruleUuid;
private String errorMessage;
private SourceType sourceType;
private String sourceId;
private EntityType entityType;
private String entityId;
private AppType appType;
private String stacktrace;
private DateTime errorDateTime;

Expand Down Expand Up @@ -68,4 +76,44 @@ public DateTime getErrorDateTime() {
public void setErrorDateTime(DateTime errorDateTime) {
this.errorDateTime = errorDateTime;
}

public SourceType getSourceType() {
return sourceType;
}

public void setSourceType(SourceType sourceType) {
this.sourceType = sourceType;
}

public String getSourceId() {
return sourceId;
}

public void setSourceId(String sourceId) {
this.sourceId = sourceId;
}

public EntityType getEntityType() {
return entityType;
}

public void setEntityType(EntityType entityType) {
this.entityType = entityType;
}

public String getEntityId() {
return entityId;
}

public void setEntityId(String entityId) {
this.entityId = entityId;
}

public AppType getAppType() {
return appType;
}

public void setAppType(AppType appType) {
this.appType = appType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ALTER TABLE public.rule_failure_telemetry
ADD COLUMN IF NOT EXISTS source_type VARCHAR(255),
ADD COLUMN IF NOT EXISTS source_id VARCHAR(255),
ADD COLUMN IF NOT EXISTS entity_type VARCHAR(255),
ADD COLUMN IF NOT EXISTS entity_id VARCHAR(255),
ADD COLUMN IF NOT EXISTS app_type VARCHAR(255);

ALTER TABLE public.rule_failure_telemetry
RENAME COLUMN close_date_time TO closed_date_time;

ALTER TABLE public.rule_failure_telemetry
ALTER COLUMN rule_uuid DROP NOT NULL;

0 comments on commit f18d663

Please sign in to comment.