Skip to content

Commit

Permalink
avniproject/avni-client#1524 | Perform init of new reportCard fields …
Browse files Browse the repository at this point in the history
…during dbMigration
  • Loading branch information
himeshr committed Sep 27, 2024
1 parent 079d89b commit 7207dab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
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;
this.durationUnit = durationUnit || Duration.Day;
}

static inDay(value) {
Expand Down
3 changes: 3 additions & 0 deletions src/ReportCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ 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
6 changes: 6 additions & 0 deletions src/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,12 @@ 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 7207dab

Please sign in to comment.