Skip to content

Commit

Permalink
Merge branch 'feat.uga-eap-classes' of https://github.com/rodekruis/I…
Browse files Browse the repository at this point in the history
…BF-system into feat.uga-eap-classes
  • Loading branch information
arsforza committed Jan 19, 2024
2 parents 42a9cf0 + a86fb12 commit 4ff9bc7
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@
><span *ngIf="actionIndicatorNumberFormat === 'perc'">{{
area.actionsValue | percent: '.0-0'
}}</span>
<span *ngIf="area.severityLevel"> - {{
area.severityLevel
<span *ngIf="area.alertClass"> - {{
area.alertClass
}}</span>
</p>
</li>
Expand Down Expand Up @@ -226,8 +226,8 @@
><span *ngIf="actionIndicatorNumberFormat === 'perc'">{{
area.actionsValue | percent: '.0-0'
}}</span>
<span *ngIf="area.severityLevel"> - {{
area.severityLevel
<span *ngIf="area.alertClass"> - {{
area.alertClass
}}</span>
</p>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class EapActionsService {
if (this.getActiveLeadtime()) {
this.triggeredAreas.forEach((area) => {
this.formatDates(area);
this.mapSeverityLevel(area);
this.mapTriggerValueToAlertClass(area);
this.filterEapActionsByMonth(area);
area.eapActions.forEach((action) => {
if (Object.keys(action.month).length) {
Expand Down Expand Up @@ -183,8 +183,8 @@ export class EapActionsService {
).toFormat('cccc, dd LLLL');
};

private mapSeverityLevel = (triggeredArea: TriggeredArea) => {
// If no match is found, then no severity level will be shown
private mapTriggerValueToAlertClass = (triggeredArea: TriggeredArea) => {
// If no match is found, then no alert class will be shown
if (this.countryDisasterSettings.eapAlertClasses) {
for (const alertClass of Object.keys(
this.countryDisasterSettings.eapAlertClasses,
Expand All @@ -193,7 +193,7 @@ export class EapActionsService {
triggeredArea.triggerValue ===
this.countryDisasterSettings.eapAlertClasses[alertClass].value
) {
triggeredArea.severityLevel = this.countryDisasterSettings.eapAlertClasses[
triggeredArea.alertClass = this.countryDisasterSettings.eapAlertClasses[
alertClass
].label;
}
Expand Down
2 changes: 1 addition & 1 deletion interfaces/IBF-dashboard/src/app/types/triggered-area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export class TriggeredArea {
stopped: boolean;
stoppedDate: string;
submitDisabled: boolean;
severityLevel?: string;
alertClass?: string;
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@
"pre-push": "^0.1.1",
"prettier": "^2.6.2",
"puppeteer": "^8.0.0"
},
"pre-commit": "lint"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export class ActivationLogDto {
@ApiProperty({ example: 100 })
public exposureValue: number;

@ApiProperty({ example: 'Maximum alert' })
public alertClass: string;

@ApiProperty({ example: '57084ea4-cac9-4f29-b955-fe9f08beb588' })
public databaseId: string;

Expand All @@ -66,6 +69,7 @@ export class ActivationLogDto {
this.manuallyStopped = null;
this.exposureIndicator = null;
this.exposureValue = null;
this.alertClass = null;
this.databaseId = null;
}
}
20 changes: 14 additions & 6 deletions services/API-service/src/api/event/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,18 @@ export class EventService {
).triggerUnit;
}

private async getCountryDisasterSettings(
countryCodeISO3: string,
disasterType: DisasterType,
) {
return (
await this.countryRepository.findOne({
where: { countryCodeISO3: countryCodeISO3 },
relations: ['countryDisasterSettings'],
})
).countryDisasterSettings.find((d) => d.disasterType === disasterType);
}

public async getTriggeredAreas(
countryCodeISO3: string,
disasterType: DisasterType,
Expand All @@ -223,12 +235,7 @@ export class EventService {
);
const triggerUnit = await this.getTriggerUnit(disasterType);
const defaultAdminLevel = (
await this.countryRepository.findOne({
where: { countryCodeISO3: countryCodeISO3 },
relations: ['countryDisasterSettings'],
})
).countryDisasterSettings.find(
(d) => d.disasterType === disasterType,
await this.getCountryDisasterSettings(countryCodeISO3, disasterType)
).defaultAdminLevel;

const whereFiltersDynamicData = {
Expand Down Expand Up @@ -415,6 +422,7 @@ export class EventService {
'case when event.closed = true then event."endDate" end as "endDate"',
'disaster."actionsUnit" as "exposureIndicator"',
'event."actionsValue" as "exposureValue"',
`CASE event."triggerValue" WHEN 1 THEN 'maximum' WHEN 0.7 THEN 'medium' WHEN 0.3 THEN 'minimum' END as "triggerValue"`,
'event."eventPlaceCodeId" as "databaseId"',
])
.leftJoin('event.adminArea', 'area')
Expand Down

0 comments on commit 4ff9bc7

Please sign in to comment.