Skip to content

Commit

Permalink
fix: improve perf by adding concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
9sneha-n committed Nov 11, 2024
1 parent 6da2ed3 commit 13ccde9
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/domain/usecases/GetAccessibleHospitals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ export class GetAccessibleHospitals {
organisationUnits: NamedRef[],
dataViewOrganisationUnits: NamedRef[]
): FutureData<{ ppsHospitals: OrgUnitAccess[]; prevalenceHospitals: OrgUnitAccess[] }> {
return Future.joinObj({
ppsHospitals: this.usersRepository.getPPSAccessibleHospitals(
organisationUnits,
dataViewOrganisationUnits
),
prevalenceHospitals: this.usersRepository.getPrevalenceAccessibleHospitals(
organisationUnits,
dataViewOrganisationUnits
),
}).flatMap(({ ppsHospitals, prevalenceHospitals }) => {
return Future.joinObj(
{
ppsHospitals: this.usersRepository.getPPSAccessibleHospitals(
organisationUnits,
dataViewOrganisationUnits
),
prevalenceHospitals: this.usersRepository.getPrevalenceAccessibleHospitals(
organisationUnits,
dataViewOrganisationUnits
),
},
{ concurrency: 2 }
).flatMap(({ ppsHospitals, prevalenceHospitals }) => {
return Future.success({
ppsHospitals: ppsHospitals,
prevalenceHospitals: prevalenceHospitals,
Expand Down

0 comments on commit 13ccde9

Please sign in to comment.