Skip to content

Commit

Permalink
feat: show alertClass in activation log AB#25984
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisvisser committed Jan 19, 2024
1 parent d5cef4f commit bb2b84f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
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 bb2b84f

Please sign in to comment.