Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix.pipeline testing changes #1618

Merged
merged 19 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9015823
fix: get glofas popup leadtime from eventName is stationCode or stati…
jannisvisser Sep 30, 2024
e855d93
fix: label ongoing in event header
jannisvisser Sep 30, 2024
96d6e74
fix: remove old glofas station endpoints
jannisvisser Sep 30, 2024
913641f
fix: only use most recent dynamic data available per point
jannisvisser Oct 1, 2024
09cfd94
chore: remove map-image feature
jannisvisser Oct 7, 2024
8de39cc
chore: Egypt removal leftover
jannisvisser Oct 7, 2024
7966275
chore: give test email more specific name
jannisvisser Oct 7, 2024
f678d99
feat: switch all countries to multi-threshold
jannisvisser Oct 7, 2024
344cc15
fix: get correct glofas dynamic data in case of warning-to-trigger sc…
jannisvisser Oct 7, 2024
0e0fe4d
fix: align warning-to-trigger email ocpy logic with portal
jannisvisser Oct 7, 2024
ad19fdc
fix: change weird apiTest variable naming
jannisvisser Oct 7, 2024
30be269
feat: disable finished-event notifications
jannisvisser Oct 7, 2024
b609590
fix: add 'first' to start date copy in email
jannisvisser Oct 8, 2024
cd005e4
fix: mock flash floods exposed point assets
jannisvisser Oct 8, 2024
2e31033
fix: make get point data query generic again
jannisvisser Oct 8, 2024
bc34903
fix: failing test by using HH:mm as default hour format convention
jannisvisser Oct 8, 2024
d2861a6
fix: use same upload date throughout api-calls when not passed
jannisvisser Oct 8, 2024
4b62637
Merge branch 'master' of https://github.com/rodekruis/IBF-system into…
jannisvisser Oct 14, 2024
58fc7d8
fix: make email body logic hazard-independent
jannisvisser Oct 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class CommunityNotificationPopupComponent implements OnInit {
ngOnInit() {
this.formattedDate = DateTime.fromISO(
this.markerProperties?.uploadTime,
).toFormat('d LLLL y, H:mm');
).toFormat('d LLLL y, HH:mm');
}

public async openPhotoPopup(url: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
}}</strong></ion-text
>
<ion-text style="font-size: 12px">{{
getTodayDate() | date: 'EEEE, H:mm z'
getTodayDate() | date: 'EEEE, HH:mm z'
}}</ion-text>
</div>
</ion-row>
Expand Down
17 changes: 10 additions & 7 deletions interfaces/IBF-dashboard/src/app/services/point-marker.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ export class PointMarkerService {
countryDisasterSettings: CountryDisasterSettings,
events: EventSummary[],
): Marker {
const activeLeadTime = events.find(
const event = events.find(
(e) =>
e.eventName ===
(markerProperties.stationCode || markerProperties.stationName), // NOTE: this assumes events to be defined per station, and eventName=stationCode or stationName
)?.firstLeadTime as LeadTime;
e.eventName === markerProperties.stationCode ||
e.eventName === markerProperties.stationName, // NOTE: this assumes events to be defined per station, and eventName=stationCode or stationName
);
// This reflects to take the trigger leadTime and not the earlier warning leadTime, in case of warning-to-trigger scenario
const eventLeadTime = (event?.firstTriggerLeadTime ||
event?.firstLeadTime) as LeadTime;

const markerTitle = markerProperties.stationName;
const markerIcon: IconOptions = {
Expand All @@ -148,7 +151,7 @@ export class PointMarkerService {
this.createMarkerStationPopup(
markerProperties,
countryDisasterSettings,
activeLeadTime,
eventLeadTime,
),
{
minWidth: 350,
Expand Down Expand Up @@ -473,10 +476,10 @@ export class PointMarkerService {
private createMarkerStationPopup(
markerProperties: Station,
countryDisasterSettings: CountryDisasterSettings,
activeLeadTime: LeadTime,
eventLeadTime: LeadTime,
) {
const lastAvailableLeadTime: LeadTime = LeadTime.day7; // Agreed with pipeline that untriggered station will always show day 7
const leadTime = activeLeadTime || lastAvailableLeadTime;
const leadTime = eventLeadTime || lastAvailableLeadTime;

const eapAlertClasses =
countryDisasterSettings?.eapAlertClasses || ({} as EapAlertClasses);
Expand Down
4 changes: 2 additions & 2 deletions interfaces/IBF-dashboard/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@
},
"active-event-active-trigger": {
"header": "{{ eventName }} on {{firstTriggerLeadTimeDate}}",
"header-ongoing": "{{ eventName }} on {{firstTriggerLeadTimeDate}}",
"header-ongoing": "{{ eventName }} ongoing",
"header-below-trigger": "{{ eventName }} on {{firstLeadTimeDate}}",
"header-ongoing-below-trigger": "{{ eventName }} on {{firstLeadTimeDate}}",
"header-ongoing-below-trigger": "{{ eventName }} ongoing",
"welcome": "Flood expected to start on {{firstLeadTimeDate}}",
"welcome-below-trigger": ""
},
Expand Down

This file was deleted.

This file was deleted.

42 changes: 0 additions & 42 deletions services/API-service/src/api/event/event-map-image.entity.ts

This file was deleted.

68 changes: 0 additions & 68 deletions services/API-service/src/api/event/event.controller.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
import stream from 'stream';
import {
Body,
Controller,
Get,
HttpException,
HttpStatus,
Param,
Post,
Query,
Res,
UploadedFile,
UseGuards,
UseInterceptors,
} from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import {
ApiBearerAuth,
ApiBody,
ApiConsumes,
ApiOperation,
ApiParam,
ApiQuery,
ApiResponse,
ApiTags,
} from '@nestjs/swagger';

import { Response } from 'express-serve-static-core';

import { Roles } from '../../roles.decorator';
import { RolesGuard } from '../../roles.guard';
import { EventSummaryCountry, TriggeredArea } from '../../shared/data.model';
import { IMAGE_UPLOAD_API_FORMAT } from '../../shared/file-upload-api-format';
import { SendNotificationDto } from '../notification/dto/send-notification.dto';
import { UserRole } from '../user/user-role.enum';
import { UserDecorator } from '../user/user.decorator';
Expand Down Expand Up @@ -217,62 +205,6 @@ export class EventController {
);
}

@UseGuards(RolesGuard)
@ApiOperation({
summary: 'Post event map image (Only .png-files supported)',
})
@ApiParam({ name: 'countryCodeISO3', required: true, type: 'string' })
@ApiParam({ name: 'disasterType', required: true, type: 'string' })
@ApiParam({ name: 'eventName', required: false, type: 'string' })
@ApiConsumes('multipart/form-data')
@ApiBody(IMAGE_UPLOAD_API_FORMAT)
@ApiResponse({ status: 200, description: 'Post event map image' })
@Post('/event-map-image/:countryCodeISO3/:disasterType/:eventName')
@UseInterceptors(FileInterceptor('image'))
public async postEventMapImage(
@UploadedFile() imageFileBlob,
@Param() params,
): Promise<void> {
await this.eventService.postEventMapImage(
params.countryCodeISO3,
params.disasterType,
params.eventName,
imageFileBlob,
);
}

@ApiOperation({
summary: 'Get event map image',
})
@ApiParam({ name: 'countryCodeISO3', required: true, type: 'string' })
@ApiParam({ name: 'disasterType', required: true, type: 'string' })
@ApiParam({ name: 'eventName', required: false, type: 'string' })
@ApiResponse({ status: 200, description: 'Get event map image' })
@Get('/event-map-image/:countryCodeISO3/:disasterType/:eventName')
public async getEventMapImage(
@Res() response: Response,
@Param() params,
): Promise<void> {
const blob = await this.eventService.getEventMapImage(
params.countryCodeISO3,
params.disasterType,
params.eventName,
);
if (!blob) {
throw new HttpException(
'Image not found. Please upload an image using POST and try again.',
HttpStatus.NOT_FOUND,
);
}
const bufferStream = new stream.PassThrough();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
bufferStream.end(Buffer.from(blob as any, 'binary'));
response.writeHead(HttpStatus.OK, {
'Content-Type': 'image/png',
});
bufferStream.pipe(response);
}

@UseGuards(RolesGuard)
@Roles(UserRole.PipelineUser)
@ApiOperation({
Expand Down
2 changes: 0 additions & 2 deletions services/API-service/src/api/event/event.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { UserEntity } from '../user/user.entity';
import { CountryModule } from './../country/country.module';
import { EapActionsModule } from './../eap-actions/eap-actions.module';
import { UserModule } from './../user/user.module';
import { EventMapImageEntity } from './event-map-image.entity';
import { EventPlaceCodeEntity } from './event-place-code.entity';
import { EventController } from './event.controller';
import { EventService } from './event.service';
Expand All @@ -30,7 +29,6 @@ import { TriggerPerLeadTime } from './trigger-per-lead-time.entity';
AdminAreaEntity,
DisasterEntity,
UserEntity,
EventMapImageEntity,
CountryEntity,
]),
],
Expand Down
48 changes: 1 addition & 47 deletions services/API-service/src/api/event/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
} from './dto/event-place-code.dto';
import { TriggerPerLeadTimeDto } from './dto/trigger-per-leadtime.dto';
import { UploadTriggerPerLeadTimeDto } from './dto/upload-trigger-per-leadtime.dto';
import { EventMapImageEntity } from './event-map-image.entity';
import { EventPlaceCodeEntity } from './event-place-code.entity';
import { TriggerPerLeadTime } from './trigger-per-lead-time.entity';

Expand All @@ -55,8 +54,6 @@ export class EventService {
private readonly disasterTypeRepository: Repository<DisasterEntity>;
@InjectRepository(UserEntity)
private readonly userRepository: Repository<UserEntity>;
@InjectRepository(EventMapImageEntity)
private readonly eventMapImageRepository: Repository<EventMapImageEntity>;
@InjectRepository(CountryEntity)
private readonly countryRepository: Repository<CountryEntity>;

Expand Down Expand Up @@ -91,7 +88,7 @@ export class EventService {
): Promise<EventSummaryCountry[]> {
const adminAreaIds = await this.getCountryAdminAreaIds(countryCodeISO3);

const sixDaysAgo = subDays(new Date(), 6);
const sixDaysAgo = subDays(new Date(), 6); // NOTE: this 7-day rule is no longer applicable. Fix this when re-enabling this feature.
const eventSummaryQueryBuilder = this.createEventSummaryQueryBuilder(
countryCodeISO3,
)
Expand Down Expand Up @@ -981,49 +978,6 @@ export class EventService {
await this.eventPlaceCodeRepo.save(aboveThresholdEvents);
}

public async postEventMapImage(
countryCodeISO3: string,
disasterType: DisasterType,
eventName: string,
imageFileBlob: { buffer: Buffer },
): Promise<void> {
let eventMapImageEntity = await this.eventMapImageRepository.findOne({
where: {
countryCodeISO3: countryCodeISO3,
disasterType: disasterType,
eventName: eventName === 'no-name' || !eventName ? IsNull() : eventName,
},
});

if (!eventMapImageEntity) {
eventMapImageEntity = new EventMapImageEntity();
eventMapImageEntity.countryCodeISO3 = countryCodeISO3;
eventMapImageEntity.disasterType = disasterType;
eventMapImageEntity.eventName =
eventName === 'no-name' ? null : eventName;
}

eventMapImageEntity.image = imageFileBlob.buffer;

this.eventMapImageRepository.save(eventMapImageEntity);
}

public async getEventMapImage(
countryCodeISO3: string,
disasterType: DisasterType,
eventName: string,
): Promise<Buffer> {
const eventMapImageEntity = await this.eventMapImageRepository.findOne({
where: {
countryCodeISO3,
disasterType,
eventName: eventName === 'no-name' || !eventName ? IsNull() : eventName,
},
});

return eventMapImageEntity?.image;
}

private async getEventEapAlertClass(
disasterSettings: CountryDisasterSettingsEntity,
eventTriggerValue: number,
Expand Down

This file was deleted.

Loading