Skip to content

Commit

Permalink
fix duration
Browse files Browse the repository at this point in the history
  • Loading branch information
fdelemarre committed Sep 17, 2024
1 parent d31a21c commit e1cdfa6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/data/repositories/AnalyticsD2Repository.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { Maybe } from "./../../utils/ts-utils";
import { AnalyticsResponse, D2Api } from "../../types/d2-api";
import { AnalyticsRepository } from "../../domain/repositories/AnalyticsRepository";
Expand Down Expand Up @@ -35,7 +36,6 @@ export type ProgramIndicatorBaseAttrs = {
creationDate: string;
suspectedDisease: string;
hazardType: string;
eventDetectionDate: string;
};

interface DiseaseEntry {
Expand Down Expand Up @@ -244,9 +244,6 @@ export class AnalyticsD2Repository implements AnalyticsRepository {
acc[key] =
Object.values(metaData.items).find(item => item.code === row[index])?.name ||
"";
} else if (key === "eventDetectionDate") {
acc.duration = `${moment().diff(moment(row[index]), "days").toString()}d`;
acc[key] = moment(row[index]).format("YYYY-MM-DD");
} else {
acc[key] = row[index] || "";
}
Expand All @@ -263,9 +260,11 @@ export class AnalyticsD2Repository implements AnalyticsRepository {
): ProgramIndicatorBaseAttrs {
const { suspectedDisease, hazardType } = baseIndicator;
const diseaseOrHazard = suspectedDisease || hazardType;

return {
...baseIndicator,
manager: event.incidentManagerName,
duration: `${moment().diff(moment(event.emerged.date), "days").toString()}d`,
cases: diseaseOrHazard ? cases[diseaseOrHazard]?.toString() || "" : "",
deaths: diseaseOrHazard ? deaths[diseaseOrHazard]?.toString() || "" : "",
} as ProgramIndicatorBaseAttrs;
Expand Down
1 change: 0 additions & 1 deletion src/data/repositories/consts/AnalyticsConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export enum IndicatorsId {
province = "ouname",
creationDate = "lastupdated",
id = "tei",
eventDetectionDate = "enrollmentdate",
}

export const NB_OF_CASES = [
Expand Down

0 comments on commit e1cdfa6

Please sign in to comment.