Skip to content

Commit

Permalink
Merge branch '10.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Oct 1, 2024
2 parents 7474af6 + 07b2f2f commit 0e3ce47
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "openchs-models",
"description": "OpenCHS data model to be used by front end clients",
"version": "1.32.15",
"version": "1.32.16",
"private": false,
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/Duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import moment from "moment";
class Duration {
constructor(durationValue, durationUnit) {
this._durationValue = durationValue;
this.durationUnit = durationUnit || Duration.Day;
this.durationUnit = durationUnit;
}

static inDay(value) {
Expand Down
3 changes: 0 additions & 3 deletions src/ReportCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ class ReportCard extends BaseEntity {
}

getStandardReportCardInputRecentDuration() {
if (_.isEmpty(this.that.standardReportCardInputRecentDurationJSON)) {
return new Duration(1, Duration.Day);
}
const duration = JSON.parse(this.that.standardReportCardInputRecentDurationJSON);
return new Duration(duration.value, duration.unit);
}
Expand Down
16 changes: 10 additions & 6 deletions src/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,16 @@ function createRealmConfig() {
newDB.delete(newDB.objects("CustomDashboardCache"));
}
if (oldDB.schemaVersion < 197) {
_.forEach(newDB.objects("ReportCard"), (reportCard) => {
if (reportCard.standardReportCardType &&
['Last 24 hours registrations', 'Last 24 hours enrolments', 'Last 24 hours visits']
.includes(reportCard.standardReportCardType.name))
reportCard.standardReportCardInputRecentDurationJSON = JSON.stringify({
value: "1",
unit: "days"
});
});

_.forEach(newDB.objects("StandardReportCardType"), (standardReportCardType) => {
if (standardReportCardType.name === 'Last 24 hours registrations') {
standardReportCardType.description = 'Recent registrations';
Expand All @@ -935,12 +945,6 @@ function createRealmConfig() {
standardReportCardType.type = _.replace(_.startCase(standardReportCardType.description), new RegExp(' ', 'g'), '');
});

_.forEach(newDB.objects(ReportCard.schema.name), (card) => {
card.standardReportCardInputSubjectTypes = [];
card.standardReportCardInputPrograms = [];
card.standardReportCardInputEncounterTypes = [];
});

//Reset MyDashboard cache because shape of filterJSON in cache has changed
const dashboardCache = newDB.objects("DashboardCache");
newDB.delete(dashboardCache);
Expand Down

0 comments on commit 0e3ce47

Please sign in to comment.