Skip to content

Commit

Permalink
fix: some renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
9sneha-n committed Sep 30, 2024
1 parent f5b9041 commit dd734a4
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 45 deletions.
7 changes: 5 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-09-16T15:12:17.095Z\n"
"PO-Revision-Date: 2024-09-16T15:12:17.095Z\n"
"POT-Creation-Date: 2024-09-30T07:39:32.843Z\n"
"PO-Revision-Date: 2024-09-30T07:39:32.843Z\n"

msgid "Low"
msgstr ""
Expand Down Expand Up @@ -81,6 +81,9 @@ msgstr ""
msgid "Edit Details"
msgstr ""

msgid "Notes"
msgstr ""

msgid "Create Event"
msgstr ""

Expand Down
4 changes: 2 additions & 2 deletions src/CompositionRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { PerformanceOverviewRepository } from "./domain/repositories/Performance
import { GetAllPerformanceOverviewMetricsUseCase } from "./domain/usecases/GetAllPerformanceOverviewMetricsUseCase";
import { PerformanceOverviewD2Repository } from "./data/repositories/PerformanceOverviewD2Repository";
import { PerformanceOverviewTestRepository } from "./data/repositories/test/PerformanceOverviewTestRepository";
import { GetDiseasesTotalUseCase } from "./domain/usecases/GetDiseasesTotalUseCase";
import { GetTotalCardCountsUseCase } from "./domain/usecases/GetDiseasesTotalUseCase";
import { MapDiseaseOutbreakToAlertsUseCase } from "./domain/usecases/MapDiseaseOutbreakToAlertsUseCase";
import { AlertRepository } from "./domain/repositories/AlertRepository";
import { AlertTestRepository } from "./data/repositories/test/AlertTestRepository";
Expand Down Expand Up @@ -66,7 +66,7 @@ function getCompositionRoot(repositories: Repositories) {
getPerformanceOverviewMetrics: new GetAllPerformanceOverviewMetricsUseCase(
repositories
),
getEventTrackerCounts: new GetDiseasesTotalUseCase(
getTotalCardCounts: new GetTotalCardCountsUseCase(
repositories.performanceOverviewRepository
),
},
Expand Down
67 changes: 31 additions & 36 deletions src/data/repositories/PerformanceOverviewD2Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { OrgUnit } from "../../domain/entities/OrgUnit";
export class PerformanceOverviewD2Repository implements PerformanceOverviewRepository {
constructor(private api: D2Api, private datastore: DataStoreClient) {}

getDiseasesTotal(filters?: Record<string, string[]>): FutureData<TotalCardCounts[]> {
getTotalCardCounts(filters?: Record<string, string[]>): FutureData<TotalCardCounts[]> {
return apiToFuture(
this.api.analytics.get({
dimension: [
Expand Down Expand Up @@ -107,32 +107,29 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos
getPerformanceOverviewMetrics(
diseaseOutbreakEvents: DiseaseOutbreakEventBaseAttrs[]
): FutureData<PerformanceOverviewMetrics[]> {
const fetchEnrollmentsQuery = (): FutureData<AnalyticsResponse> =>
apiToFuture(
this.api.get<AnalyticsResponse>(
`/analytics/enrollments/query/${RTSL_ZEBRA_PROGRAM_ID}`,
{
enrollmentDate: "LAST_12_MONTHS,THIS_MONTH",
dimension: [
IndicatorsId.suspectedDisease,
IndicatorsId.hazardType,
IndicatorsId.event,
IndicatorsId.era1,
IndicatorsId.era2,
IndicatorsId.era3,
IndicatorsId.era4,
IndicatorsId.era5,
IndicatorsId.era6,
IndicatorsId.era7,
IndicatorsId.detect7d,
IndicatorsId.notify1d,
IndicatorsId.respond7d,
],
}
)
);

return fetchEnrollmentsQuery().flatMap(indicatorsProgramFuture => {
return apiToFuture(
this.api.get<AnalyticsResponse>(
`/analytics/enrollments/query/${RTSL_ZEBRA_PROGRAM_ID}`,
{
enrollmentDate: "LAST_12_MONTHS,THIS_MONTH",
dimension: [
IndicatorsId.suspectedDisease,
IndicatorsId.hazardType,
IndicatorsId.event,
IndicatorsId.era1,
IndicatorsId.era2,
IndicatorsId.era3,
IndicatorsId.era4,
IndicatorsId.era5,
IndicatorsId.era6,
IndicatorsId.era7,
IndicatorsId.detect7d,
IndicatorsId.notify1d,
IndicatorsId.respond7d,
],
}
)
).flatMap(indicatorsProgramFuture => {
const mappedIndicators =
indicatorsProgramFuture?.rows.map((row: string[]) =>
this.mapRowToBaseIndicator(
Expand All @@ -143,20 +140,20 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos
)
) || [];

const something = diseaseOutbreakEvents.map(event => {
const performanceOverviewMetrics = diseaseOutbreakEvents.map(event => {
const baseIndicator = mappedIndicators.find(indicator => indicator.id === event.id);

const key = baseIndicator?.suspectedDisease || baseIndicator?.hazardType;

return this.getCasesAndDeathsFromDatastore(key).map(casesAndDeaths => {
const duration = `${moment()
.diff(moment(event.emerged.date), "days")
.toString()}d`;
if (!baseIndicator) {
return {
id: event.id,
event: event.name,
manager: event.incidentManagerName,
duration: `${moment()
.diff(moment(event.emerged.date), "days")
.toString()}d`,
duration: duration,
nationalIncidentStatus: event.incidentStatus,
cases: casesAndDeaths.cases.toString(),
deaths: casesAndDeaths.deaths.toString(),
Expand All @@ -166,16 +163,14 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos
...baseIndicator,
nationalIncidentStatus: event.incidentStatus,
manager: event.incidentManagerName,
duration: `${moment()
.diff(moment(event.emerged.date), "days")
.toString()}d`,
duration: duration,
cases: casesAndDeaths.cases.toString(),
deaths: casesAndDeaths.deaths.toString(),
} as PerformanceOverviewMetrics;
});
});

return Future.sequential(something);
return Future.sequential(performanceOverviewMetrics);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PerformanceOverviewRepository } from "../../../domain/repositories/Perf
import { FutureData } from "../../api-futures";

export class PerformanceOverviewTestRepository implements PerformanceOverviewRepository {
getDiseasesTotal(): FutureData<any> {
getTotalCardCounts(): FutureData<any> {
return Future.success(0);
}
getPerformanceOverviewMetrics(): FutureData<any[]> {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/repositories/PerformanceOverviewRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export interface PerformanceOverviewRepository {
getPerformanceOverviewMetrics(
diseaseOutbreakEvents: DiseaseOutbreakEventBaseAttrs[]
): FutureData<PerformanceOverviewMetrics[]>;
getDiseasesTotal(filters?: Record<string, string[]>): FutureData<TotalCardCounts[]>;
getTotalCardCounts(filters?: Record<string, string[]>): FutureData<TotalCardCounts[]>;
}
4 changes: 2 additions & 2 deletions src/domain/usecases/GetDiseasesTotalUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { FutureData } from "../../data/api-futures";
import { TotalCardCounts } from "../entities/disease-outbreak-event/PerformanceOverviewMetrics";
import { PerformanceOverviewRepository } from "../repositories/PerformanceOverviewRepository";

export class GetDiseasesTotalUseCase {
export class GetTotalCardCountsUseCase {
constructor(private performanceOverviewRepository: PerformanceOverviewRepository) {}

public execute(filters?: Record<string, string[]>): FutureData<TotalCardCounts[]> {
return this.performanceOverviewRepository.getDiseasesTotal(filters);
return this.performanceOverviewRepository.getTotalCardCounts(filters);
}
}
2 changes: 1 addition & 1 deletion src/webapp/pages/dashboard/useCardCounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function useCardCounts(filters: Record<string, string[]>) {

useEffect(() => {
setIsLoading(true);
compositionRoot.performanceOverview.getEventTrackerCounts.execute(filters).run(
compositionRoot.performanceOverview.getTotalCardCounts.execute(filters).run(
diseasesTotal => {
setCardCounts(diseasesTotal);
setIsLoading(false);
Expand Down

0 comments on commit dd734a4

Please sign in to comment.