Skip to content

Commit

Permalink
Merge pull request #1505 from rodekruis/refactor.date-fns
Browse files Browse the repository at this point in the history
feat: use date-fns library for date operations
  • Loading branch information
gulfaraz authored Jul 12, 2024
2 parents baafe39 + 21141b4 commit 301f059
Show file tree
Hide file tree
Showing 152 changed files with 1,475 additions and 884 deletions.
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80,
"no-parameter-properties": true,
"tabWidth": 2
}
5 changes: 4 additions & 1 deletion services/API-service/.prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module.exports = {
trailingComma: 'all',
singleQuote: true,
printWidth: 80,
'no-parameter-properties': true,
tabWidth: 2,
plugins: ['@ianvs/prettier-plugin-sort-imports'],
importOrder: ['^@nestjs', '', '<THIRD_PARTY_MODULES>', '', '^[.]'],
importOrderParserPlugins: ['typescript', 'jsx', 'decorators-legacy'],
importOrderTypeScriptVersion: '5.0.0',
};
2 changes: 2 additions & 0 deletions services/API-service/appdatasource.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { DataSource, DataSourceOptions } from 'typeorm';

import { ORMConfig } from './ormconfig';

export const AppDataSource = new DataSource(ORMConfig as DataSourceOptions);
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import * as fs from 'fs';
import * as path from 'path';

import { MigrationInterface, QueryRunner } from 'typeorm';

export class RenameMockRasters1710512991479 implements MigrationInterface {
public async up(_queryRunner: QueryRunner): Promise<void> {
const directoryPath = './geoserver-volume/raster-files/mock-output/';
Expand Down
1 change: 1 addition & 0 deletions services/API-service/ormconfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as fs from 'fs';

import { DataSourceOptions } from 'typeorm';

export const ORMConfig: DataSourceOptions = {
Expand Down
1,095 changes: 731 additions & 364 deletions services/API-service/package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions services/API-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"class-transformer": "^0.3.1",
"class-validator": "^0.14.0",
"csv-parser": "^3.0.0",
"date-fns": "^3.6.0",
"ejs": "^3.1.9",
"jsonwebtoken": "^8.1.1",
"juice": "^10.0.0",
Expand All @@ -56,6 +57,7 @@
"wkt-io-ts": "^1.0.2"
},
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.3.0",
"@types/express": "^4.17.14",
"@types/jest": "^26.0.20",
"@types/node": "16.x",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ import {
ApiResponse,
ApiTags,
} from '@nestjs/swagger';

import { Roles } from '../../roles.decorator';
import { RolesGuard } from '../../roles.guard';
import { FILE_UPLOAD_API_FORMAT } from '../../shared/file-upload-api-format';
import { AdminDataReturnDto } from '../admin-area-dynamic-data/dto/admin-data-return.dto';
import { UserRole } from '../user/user-role.enum';
import { AdminAreaDataService } from './admin-area-data.service';
import { UploadAdminAreaDataJsonDto } from './dto/upload-admin-area-data.dto';
import { FILE_UPLOAD_API_FORMAT } from '../../shared/file-upload-api-format';

@ApiBearerAuth()
@UseGuards(RolesGuard)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
ManyToOne,
JoinColumn,
Entity,
Index,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
} from 'typeorm';

import { AdminLevel } from '../country/admin-level.enum';
import { CountryEntity } from '../country/country.entity';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

import { HelperService } from '../../shared/helper.service';
import { UserModule } from '../user/user.module';
import { AdminAreaDataController } from './admin-area-data.controller';
import { AdminAreaDataEntity } from './admin-area-data.entity';
import { AdminAreaDataService } from './admin-area-data.service';
import { HttpModule } from '@nestjs/axios';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';

import { validate } from 'class-validator';
import { Repository } from 'typeorm';

import { HelperService } from '../../shared/helper.service';
import { AdminDataReturnDto } from '../admin-area-dynamic-data/dto/admin-data-return.dto';
import { UpdateableStaticIndicator } from '../admin-area-dynamic-data/enum/dynamic-data-unit';
import { AdminAreaDataEntity } from './admin-area-data.entity';
import {
UploadAdminAreaDataDto,
UploadAdminAreaDataJsonDto,
} from './dto/upload-admin-area-data.dto';
import { validate } from 'class-validator';
import { AdminDataReturnDto } from '../admin-area-dynamic-data/dto/admin-data-return.dto';
import { HelperService } from '../../shared/helper.service';
import { UpdateableStaticIndicator } from '../admin-area-dynamic-data/enum/dynamic-data-unit';

@Injectable()
export class AdminAreaDataService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';

import { Type } from 'class-transformer';
import {
IsArray,
IsEnum,
Expand All @@ -7,14 +10,13 @@ import {
IsString,
ValidateNested,
} from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { ManyToOne, JoinColumn } from 'typeorm';
import { JoinColumn, ManyToOne } from 'typeorm';

import { DynamicDataPlaceCodeDto } from '../../admin-area-dynamic-data/dto/dynamic-data-place-code.dto';
import indicatorData from '../../admin-area-dynamic-data/dto/example/ETH/malaria/upload-potential_cases-3.json';
import { UpdateableStaticIndicator } from '../../admin-area-dynamic-data/enum/dynamic-data-unit';
import { AdminLevel } from '../../country/admin-level.enum';
import { CountryEntity } from '../../country/country.entity';
import indicatorData from '../../admin-area-dynamic-data/dto/example/ETH/malaria/upload-potential_cases-3.json';

export class UploadAdminAreaDataDto {
@ApiProperty()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
import { AdminDataReturnDto } from './dto/admin-data-return.dto';
import { DynamicIndicator } from './enum/dynamic-data-unit';
import { Body, Get, Param, UploadedFile } from '@nestjs/common';
import { Controller, Post, UseGuards, UseInterceptors } from '@nestjs/common';
import {
ApiOperation,
ApiConsumes,
Body,
Controller,
Get,
Param,
Post,
UploadedFile,
UseGuards,
UseInterceptors,
} from '@nestjs/common';
import { Query } from '@nestjs/common/decorators';
import { FileInterceptor } from '@nestjs/platform-express';
import {
ApiBearerAuth,
ApiTags,
ApiParam,
ApiBody,
ApiResponse,
ApiConsumes,
ApiOperation,
ApiParam,
ApiQuery,
ApiResponse,
ApiTags,
} from '@nestjs/swagger';

import { Roles } from '../../roles.decorator';
import { RolesGuard } from '../../roles.guard';
import { UploadAdminAreaDynamicDataDto } from './dto/upload-admin-area-dynamic-data.dto';
import { AdminAreaDynamicDataService } from './admin-area-dynamic-data.service';
import { FILE_UPLOAD_API_FORMAT } from '../../shared/file-upload-api-format';
import { DisasterType } from '../disaster/disaster-type.enum';
import { FileInterceptor } from '@nestjs/platform-express';
import { Roles } from '../../roles.decorator';
import { UserRole } from '../user/user-role.enum';
import { Query } from '@nestjs/common/decorators';
import { FILE_UPLOAD_API_FORMAT } from '../../shared/file-upload-api-format';
import { AdminAreaDynamicDataService } from './admin-area-dynamic-data.service';
import { AdminDataReturnDto } from './dto/admin-data-return.dto';
import { UploadAdminAreaDynamicDataDto } from './dto/upload-admin-area-dynamic-data.dto';
import { DynamicIndicator } from './enum/dynamic-data-unit';

@ApiBearerAuth()
@UseGuards(RolesGuard)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
ManyToOne,
JoinColumn,
Entity,
Index,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
} from 'typeorm';

import { CountryEntity } from '../country/country.entity';
import { DisasterEntity } from '../disaster/disaster.entity';
import { LeadTimeEntity } from '../lead-time/lead-time.entity';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { CountryModule } from './../country/country.module';
import { UserModule } from '../user/user.module';
import { AdminAreaDynamicDataService } from './admin-area-dynamic-data.service';
import { AdminAreaDynamicDataController } from './admin-area-dynamic-data.controller';
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { TriggerPerLeadTime } from '../event/trigger-per-lead-time.entity';
import { AdminAreaDynamicDataEntity } from './admin-area-dynamic-data.entity';
import { EventModule } from '../event/event.module';
import { DisasterEntity } from '../disaster/disaster.entity';
import { CountryEntity } from '../country/country.entity';

import { HelperService } from '../../shared/helper.service';
import { AdminAreaModule } from '../admin-area/admin-area.module';
import { CountryEntity } from '../country/country.entity';
import { DisasterEntity } from '../disaster/disaster.entity';
import { EventModule } from '../event/event.module';
import { TriggerPerLeadTime } from '../event/trigger-per-lead-time.entity';
import { UserModule } from '../user/user.module';
import { CountryModule } from './../country/country.module';
import { AdminAreaDynamicDataController } from './admin-area-dynamic-data.controller';
import { AdminAreaDynamicDataEntity } from './admin-area-dynamic-data.entity';
import { AdminAreaDynamicDataService } from './admin-area-dynamic-data.service';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { LeadTime } from './enum/lead-time.enum';
import { DynamicDataPlaceCodeDto } from './dto/dynamic-data-place-code.dto';
import fs from 'fs';
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { DataSource, In, IsNull, MoreThanOrEqual, Repository } from 'typeorm';
import { UploadAdminAreaDynamicDataDto } from './dto/upload-admin-area-dynamic-data.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { AdminAreaDynamicDataEntity } from './admin-area-dynamic-data.entity';
import { DynamicIndicator } from './enum/dynamic-data-unit';
import { AdminDataReturnDto } from './dto/admin-data-return.dto';
import { UploadTriggerPerLeadTimeDto } from '../event/dto/upload-trigger-per-leadtime.dto';
import { EventService } from '../event/event.service';
import { DisasterEntity } from '../disaster/disaster.entity';
import { DisasterType } from '../disaster/disaster-type.enum';
import fs from 'fs';
import { CountryEntity } from '../country/country.entity';

import { DataSource, In, IsNull, MoreThanOrEqual, Repository } from 'typeorm';

import { DisasterTypeGeoServerMapper } from '../../scripts/disaster-type-geoserver-file.mapper';
import { HelperService } from '../../shared/helper.service';
import { EventAreaService } from '../admin-area/services/event-area.service';
import { DisasterTypeGeoServerMapper } from '../../scripts/disaster-type-geoserver-file.mapper';
import { CountryEntity } from '../country/country.entity';
import { DisasterType } from '../disaster/disaster-type.enum';
import { DisasterEntity } from '../disaster/disaster.entity';
import { UploadTriggerPerLeadTimeDto } from '../event/dto/upload-trigger-per-leadtime.dto';
import { EventService } from '../event/event.service';
import { AdminAreaDynamicDataEntity } from './admin-area-dynamic-data.entity';
import { AdminDataReturnDto } from './dto/admin-data-return.dto';
import { DynamicDataPlaceCodeDto } from './dto/dynamic-data-place-code.dto';
import { UploadAdminAreaDynamicDataDto } from './dto/upload-admin-area-dynamic-data.dto';
import { DynamicIndicator } from './enum/dynamic-data-unit';
import { LeadTime } from './enum/lead-time.enum';

interface RasterData {
originalname: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IsNotEmpty, IsNumber, IsString } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

import { IsNotEmpty, IsNumber, IsString } from 'class-validator';

export class DynamicDataPlaceCodeDto {
@ApiProperty()
@IsNotEmpty()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';

import { Type } from 'class-transformer';
import {
IsArray,
IsEnum,
Expand All @@ -7,13 +10,12 @@ import {
IsString,
ValidateNested,
} from 'class-validator';
import { Type } from 'class-transformer';
import { ApiProperty } from '@nestjs/swagger';

import { DisasterType } from '../../disaster/disaster-type.enum';
import { DynamicIndicator } from '../enum/dynamic-data-unit';
import { LeadTime } from '../enum/lead-time.enum';
import { DynamicDataPlaceCodeDto } from './dynamic-data-place-code.dto';
import exposure from './example/PHL/dengue/upload-potential_cases-2.json';
import { LeadTime } from '../enum/lead-time.enum';
import { DynamicIndicator } from '../enum/dynamic-data-unit';
import { DisasterType } from '../../disaster/disaster-type.enum';

export class UploadAdminAreaDynamicDataDto {
@ApiProperty({ example: 'PHL' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ import {
ApiResponse,
ApiTags,
} from '@nestjs/swagger';
import { GeoJson } from '../../shared/geo.model';

import { Roles } from '../../roles.decorator';
import { RolesGuard } from '../../roles.guard';
import { AdminAreaService } from './admin-area.service';
import { AggregateDataRecord } from '../../shared/data.model';
import { AdminAreaEntity } from './admin-area.entity';
import { Roles } from '../../roles.decorator';
import { GeoJson } from '../../shared/geo.model';
import { UserRole } from '../user/user-role.enum';
import { AdminAreaEntity } from './admin-area.entity';
import { AdminAreaService } from './admin-area.service';

@ApiBearerAuth()
@UseGuards(RolesGuard)
Expand Down
12 changes: 7 additions & 5 deletions services/API-service/src/api/admin-area/admin-area.entity.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { ApiProperty } from '@nestjs/swagger';

import {
Entity,
PrimaryGeneratedColumn,
Column,
ManyToOne,
JoinColumn,
OneToMany,
Entity,
Index,
JoinColumn,
ManyToOne,
MultiPolygon,
OneToMany,
PrimaryGeneratedColumn,
} from 'typeorm';

import { CountryEntity } from '../country/country.entity';
import { EventPlaceCodeEntity } from '../event/event-place-code.entity';

Expand Down
11 changes: 6 additions & 5 deletions services/API-service/src/api/admin-area/admin-area.module.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { CountryModule } from './../country/country.module';
import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

import { HelperService } from '../../shared/helper.service';
import { AdminAreaDynamicDataEntity } from '../admin-area-dynamic-data/admin-area-dynamic-data.entity';
import { CountryEntity } from '../country/country.entity';
import { DisasterEntity } from '../disaster/disaster.entity';
import { EventModule } from '../event/event.module';
import { UserModule } from '../user/user.module';
import { CountryModule } from './../country/country.module';
import { AdminAreaController } from './admin-area.controller';
import { AdminAreaEntity } from './admin-area.entity';
import { AdminAreaService } from './admin-area.service';
import { DisasterEntity } from '../disaster/disaster.entity';
import { AdminAreaDynamicDataEntity } from '../admin-area-dynamic-data/admin-area-dynamic-data.entity';
import { HttpModule } from '@nestjs/axios';
import { EventAreaService } from './services/event-area.service';
import { EventAreaEntity } from './event-area.entity';
import { EventAreaService } from './services/event-area.service';

@Module({
imports: [
Expand Down
Loading

0 comments on commit 301f059

Please sign in to comment.