-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #484 from EyeSeeTea/development
Release 1.4
- Loading branch information
Showing
17 changed files
with
329 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { D2Api, Id } from "../../types/d2-api"; | ||
import { Debug, Migration } from "../types"; | ||
import { post } from "./common"; | ||
import { getUid } from "../../utils/dhis2"; | ||
|
||
class AddLastUpdatedDataMigration { | ||
constructor(private api: D2Api, private debug: Debug) {} | ||
|
||
private async post<Payload>(payload: Payload) { | ||
await post(this.api, this.debug, payload); | ||
} | ||
|
||
async execute() { | ||
await this.createAttributeForOrgUnitLastUpdated(); | ||
} | ||
|
||
async createAttributeForOrgUnitLastUpdated() { | ||
this.debug( | ||
"Create the attribute metadata to store last update data for organisation units" | ||
); | ||
return this.post({ | ||
attributes: [ | ||
{ | ||
id: getId("attributes", "last-updated-org-unit"), | ||
name: "Last Updated Data", | ||
code: "DM_LAST_UPDATED_DATA", | ||
valueType: "DATETIME", | ||
dataSetAttribute: true, | ||
}, | ||
], | ||
}); | ||
} | ||
} | ||
|
||
function getId(model: string, key: string): Id { | ||
return getUid(model + "-", key); | ||
} | ||
|
||
const migration: Migration = { | ||
name: "Create the attribute metadata to store last update data for organisation units", | ||
migrate: async (api: D2Api, debug: Debug) => | ||
new AddLastUpdatedDataMigration(api, debug).execute(), | ||
}; | ||
|
||
export default migration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.