Skip to content

Commit

Permalink
Upload case data file always with same name and the disease outbreak …
Browse files Browse the repository at this point in the history
…event id. Upload file with correct sharing settings
  • Loading branch information
anagperal committed Jan 2, 2025
1 parent 0a30766 commit 3635fc3
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
4 changes: 2 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-12-23T12:10:07.048Z\n"
"PO-Revision-Date: 2024-12-23T12:10:07.048Z\n"
"POT-Creation-Date: 2025-01-02T13:42:25.737Z\n"
"PO-Revision-Date: 2025-01-02T13:42:25.737Z\n"

msgid "Low"
msgstr ""
Expand Down
54 changes: 50 additions & 4 deletions src/data/repositories/CasesFileD2Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ export class CasesFileD2Repository implements CasesFileRepository {
}

save(diseaseOutbreakEventId: Id, outbreakKey: string, caseFile: CaseFile): FutureData<void> {
const renamedUploadedCasesDataFile = new File(
[caseFile.file],
`HISTORICAL_CASE_DATA_${diseaseOutbreakEventId}`,
{
type: caseFile.file.type,
}
);

return Future.joinObj({
fileId: this.uploadCasesFile(caseFile.file),
fileId: this.uploadCasesFile(renamedUploadedCasesDataFile),
alertsAndCaseForCasesData: this.getAlertsAndCaseForCasesDataObject(outbreakKey),
}).flatMap(({ fileId, alertsAndCaseForCasesData }) => {
const newAlertsAndCaseForCasesData: AlertsAndCaseForCasesData = {
Expand All @@ -62,8 +70,8 @@ export class CasesFileD2Repository implements CasesFileRepository {
nationalDiseaseOutbreakEventId: diseaseOutbreakEventId,
case: {
fileId,
fileName: caseFile.file.name,
fileType: caseFile.file.type,
fileName: renamedUploadedCasesDataFile.name,
fileType: renamedUploadedCasesDataFile.type,
},
};
return this.saveAlertsAndCaseForCasesDataObject(
Expand Down Expand Up @@ -113,7 +121,45 @@ export class CasesFileD2Repository implements CasesFileRepository {
name: file.name,
data: file,
})
).map(response => response.id);
).flatMap(response => {
return this.dataStoreClient
.getObject<AppDatastoreConfig>("app-config")
.flatMap(appConfig => {
const captureAccessUserGroups = [
...(appConfig?.userGroups.admin || []),
...(appConfig?.userGroups.capture || []),
].map(userGroupId => ({
access: "rw------",
id: userGroupId,
}));

const visualizerAccessUserGroups = [
...(appConfig?.userGroups.visualizer || []),
].map(userGroupId => ({
access: "r-------",
id: userGroupId,
}));

return apiToFuture(
this.api.sharing.post(
{
id: response.id,
type: "document",
},
{
externalAccess: false,
publicAccess: "--------",
userGroupAccesses: [
...captureAccessUserGroups,
...visualizerAccessUserGroups,
],
}
)
).flatMap(() => {
return Future.success(response.id);
});
});
});
}

private deleteCasesFile(fileId: Id): FutureData<void> {
Expand Down

0 comments on commit 3635fc3

Please sign in to comment.