Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: work on review AB#6356
Browse files Browse the repository at this point in the history
RubenGeo committed Mar 1, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 7aa306a commit 1e2c557
Showing 10 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -225,10 +225,13 @@ export class ChatComponent implements OnDestroy {
eventPlaceCodeId: number,
placeCode: string,
) {
await this.apiService.closeEventPlaceCode(eventPlaceCodeId);
this.filteredAreas = this.filteredAreas.filter(
(item) => item.id !== eventPlaceCodeId,
);
let loading = await this.loadingCtrl.create({});
loading.present();
this.apiService.closeEventPlaceCode(eventPlaceCodeId).then(() => {
loading.dismiss();
});
this.eapActionsService.loadDistrictsAndActions();
this.eventService.getTrigger();
this.countryService
.getCountrySubscription()
.subscribe((country: Country) => {
@@ -240,10 +243,5 @@ export class ChatComponent implements OnDestroy {
placeCode: placeCode,
});
});
let loading = await this.loadingCtrl.create({});
loading.present();
setTimeout(() => {
loading.dismiss();
}, 1000);
}
}
4 changes: 2 additions & 2 deletions interfaces/IBF-dashboard/src/app/services/api.service.ts
Original file line number Diff line number Diff line change
@@ -202,11 +202,11 @@ export class ApiService {
).toPromise();
}

closeEventPlaceCode(eventPlacecodeId: number) {
closeEventPlaceCode(eventPlaceCodeId: number) {
return this.post(
'event/close-place-code',
{
eventPlacecodeId,
eventPlaceCodeId,
},
false,
).toPromise();
12 changes: 8 additions & 4 deletions services/API-service/src/api/data/data.controller.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import {
} from '@nestjs/swagger';
import { RolesGuard } from '../../roles.guard';

import { TriggeredArea, CountryEvent } from './data.model';
import { TriggeredArea, EventSummaryCountry } from './data.model';
import { DataService } from './data.service';
import { GeoJson } from './geo.model';

@@ -74,10 +74,14 @@ export class DataController {
return await this.dataService.getTriggeredAreas(params.countryCode);
}

@ApiOperation({ summary: 'Get active country event' })
@ApiOperation({ summary: 'Get active event summary of a country' })
@ApiParam({ name: 'countryCodeISO3', required: true, type: 'string' })
@Get('event/:countryCodeISO3')
public async getCountryEvent(@Param() params): Promise<CountryEvent> {
return await this.dataService.getCountryEvent(params.countryCodeISO3);
public async getEventSummaryCountry(
@Param() params,
): Promise<EventSummaryCountry> {
return await this.dataService.getEventSummaryCountry(
params.countryCodeISO3,
);
}
}
2 changes: 1 addition & 1 deletion services/API-service/src/api/data/data.model.ts
Original file line number Diff line number Diff line change
@@ -135,7 +135,7 @@ export class TriggeredArea {
public population_affected: number;
}

export class CountryEvent {
export class EventSummaryCountry {
public country_code: string;
public startDate: string;
public endDate: string;
8 changes: 5 additions & 3 deletions services/API-service/src/api/data/data.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CountryEvent } from './data.model';
import { EventSummaryCountry } from './data.model';
/* eslint-disable @typescript-eslint/camelcase */
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
@@ -130,9 +130,11 @@ export class DataService {
return result;
}

public async getCountryEvent(countryCodeISO3: string): Promise<CountryEvent> {
public async getEventSummaryCountry(
countryCodeISO3: string,
): Promise<EventSummaryCountry> {
const query = fs
.readFileSync('./src/api/data/sql/get-country-event.sql')
.readFileSync('./src/api/data/sql/get-event-summary-country.sql')
.toString();
const result = await this.manager.query(query, [countryCodeISO3]);
if (!result[0].startDate) {
Original file line number Diff line number Diff line change
@@ -5,5 +5,5 @@ export class EventPlaceCodeDto {
@ApiProperty()
@IsNotEmpty()
@IsNumber()
public eventPlacecodeId: number;
public eventPlaceCodeId: number;
}
2 changes: 1 addition & 1 deletion services/API-service/src/api/event/event.service.spec.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import { getRepositoryToken } from '@nestjs/typeorm';
import { repositoryMockFactory } from '../../mock/repositoryMock.factory';
import { EventPlaceCodeEntity } from './event-place-code.entity';

describe('User service', (): void => {
describe('Event service', (): void => {
let service: EventService;
beforeAll(
async (): Promise<void> => {
2 changes: 1 addition & 1 deletion services/API-service/src/api/event/event.service.ts
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ export class EventService {
eventPlaceCodeDto: EventPlaceCodeDto,
): Promise<void> {
const eventPlaceCode = await this.eventPlaceCodeRepo.findOne(
eventPlaceCodeDto.eventPlacecodeId,
eventPlaceCodeDto.eventPlaceCodeId,
);
if (!eventPlaceCode) {
const errors = 'Event Pcode not found';
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ export class IndicatorService {
i.country_codes.split(',').includes(countryCode),
);

const event = await this.dataService.getCountryEvent(countryCode);
const event = await this.dataService.getEventSummaryCountry(countryCode);
const activeTrigger = event && event.activeTrigger;
countryIndicators.find(
(i): boolean => i.name === 'population_affected',

0 comments on commit 1e2c557

Please sign in to comment.