Skip to content

Commit

Permalink
feat: perf optimization, hospital data processed in less than a second
Browse files Browse the repository at this point in the history
  • Loading branch information
9sneha-n committed Jan 5, 2024
1 parent 67ea36d commit 8066409
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 131 deletions.
12 changes: 10 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-01-01T15:15:58.433Z\n"
"PO-Revision-Date: 2024-01-01T15:15:58.433Z\n"
"POT-Creation-Date: 2024-01-05T16:06:58.231Z\n"
"PO-Revision-Date: 2024-01-05T16:06:58.231Z\n"

msgid "WHO privacy policy"
msgstr ""
Expand Down Expand Up @@ -82,6 +82,11 @@ msgstr ""
msgid "HOSP"
msgstr ""

msgid ""
"This survey has other surveys associated with it.\n"
" Please delete all associated surveys, before you can delete this one."
msgstr ""

msgid "Survey deleted!"
msgstr ""

Expand Down Expand Up @@ -121,6 +126,9 @@ msgstr ""
msgid "Hospital Code"
msgstr ""

msgid "Loading..."
msgstr ""

msgid "Yes"
msgstr ""

Expand Down
29 changes: 8 additions & 21 deletions src/data/repositories/UserD2Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,9 @@ export class UserD2Repository implements UserRepository {
},
fields: {
id: true,
name: true,
shortName: true,
code: true,
path: true,
level: true,
parent: {
id: true,
},
},
paging: false,
})
Expand All @@ -142,10 +137,9 @@ export class UserD2Repository implements UserRepository {
res.objects.map(ou => {
if (!ou.path.includes(NA_OU_ID))
return {
name: ou.name,
id: ou.id,
shortName: ou.shortName,
code: ou.code,

path: ou.path,
};
})
Expand All @@ -162,6 +156,7 @@ export class UserD2Repository implements UserRepository {
const userDataViewOrgUnits = allLevelOUs.filter(levelOU =>
dataViewOrganisationUnits.some(userOU => levelOU.path.includes(userOU.id))
);

return Future.success({ userOrgUnits, userDataViewOrgUnits });
});
};
Expand All @@ -170,34 +165,26 @@ export class UserD2Repository implements UserRepository {
organisationUnits: OrgUnit[],
dataViewOrganisationUnits: OrgUnit[]
): OrgUnitAccess[] => {
let orgUnitsAccess = organisationUnits.map(ou => ({
const orgUnitsAccess: OrgUnitAccess[] = organisationUnits.map(ou => ({
orgUnitId: ou.id,
orgUnitName: ou.name,
orgUnitShortName: ou.shortName,
orgUnitCode: ou.code,
orgUnitPath: ou.path,
readAccess: dataViewOrganisationUnits.some(dvou => dvou.id === ou.id),
readAccess: dataViewOrganisationUnits.includes(ou),
captureAccess: true,
}));

//Setting view access for org units that are present in dataViewOrganisationUnits and not organisationUnits
const readOnlyAccessOrgUnits = dataViewOrganisationUnits
.filter(dvou => orgUnitsAccess.every(oua => oua.orgUnitId !== dvou.id))
const readOnlyAccessOrgUnits: OrgUnitAccess[] = dataViewOrganisationUnits
.filter(dvou => !organisationUnits.includes(dvou))
.map(raou => ({
orgUnitId: raou.id,
orgUnitName: raou.name,
orgUnitShortName: raou.shortName,
orgUnitCode: raou.code,
orgUnitPath: raou.path,
readAccess: true,
captureAccess: false, //orgUnits in dataViewOrganisationUnits dont have capture access
}));

orgUnitsAccess = [...orgUnitsAccess, ...readOnlyAccessOrgUnits].sort((a, b) =>
a.orgUnitShortName.localeCompare(b.orgUnitShortName)
);

return orgUnitsAccess;
const newOrgUnitsAccess: OrgUnitAccess[] = [...orgUnitsAccess, ...readOnlyAccessOrgUnits];
return newOrgUnitsAccess;
};

saveLocale(isUiLocale: boolean, locale: string): FutureData<void> {
Expand Down
2 changes: 0 additions & 2 deletions src/domain/entities/OrgUnit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export interface OrgUnit {
name: string;
id: string;
shortName: string;
code: string;
path: string;
}
2 changes: 0 additions & 2 deletions src/domain/entities/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { Id, NamedRef } from "./Ref";

export interface OrgUnitAccess {
orgUnitId: Id;
orgUnitName: string;
orgUnitShortName: string;
orgUnitCode: string;
orgUnitPath: string;
readAccess: boolean;
captureAccess: boolean;
Expand Down
3 changes: 3 additions & 0 deletions src/domain/usecases/GetUserAccessibleOUByLevel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export class GetUserAccessibleOUByLevel {
organisationUnits: NamedRef[],
dataViewOrganisationUnits: NamedRef[]
): FutureData<OrgUnitAccess[]> {



return this.usersRepository.getCurrentOUByLevel(
organisationUnits,
dataViewOrganisationUnits
Expand Down
2 changes: 1 addition & 1 deletion src/webapp/components/user-profile/UserProfileContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const UserProfileContent: React.FC<UserProfileContentProps> = ({ userInfo
<StyledChip
size="small"
key={orgUnits.orgUnitId}
label={orgUnits.orgUnitName}
label={orgUnits.orgUnitShortName}
color="primary"
/>
)
Expand Down
103 changes: 0 additions & 103 deletions src/workers/getHospitalWorker.ts

This file was deleted.

0 comments on commit 8066409

Please sign in to comment.