-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dynamic point data entity + gauge layer AB#25124
- Loading branch information
1 parent
9153160
commit bfc3071
Showing
14 changed files
with
300 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
services/API-service/migration/1701157179286-DynamicPointData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class DynamicPointData1701157179286 implements MigrationInterface { | ||
name = 'DynamicPointData1701157179286'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE TABLE "IBF-app"."dynamic-point-data" ("dynamicPointDataId" uuid NOT NULL DEFAULT uuid_generate_v4(), "timestamp" TIMESTAMP NOT NULL, "key" character varying NOT NULL, "value" character varying, "pointPointDataId" uuid, "leadTime" character varying, CONSTRAINT "PK_4f51e8c4a1091afa35e3cc51b34" PRIMARY KEY ("dynamicPointDataId"))`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "IBF-app"."dynamic-point-data" ADD CONSTRAINT "FK_9aaa9be5dbe82b610209bcb456b" FOREIGN KEY ("pointPointDataId") REFERENCES "IBF-app"."point-data"("pointDataId") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "IBF-app"."dynamic-point-data" ADD CONSTRAINT "FK_289a1f52e25e270d9a28bd9d35a" FOREIGN KEY ("leadTime") REFERENCES "IBF-app"."lead-time"("leadTimeName") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
|
||
// NOTE: Do not prioritize this, but leave the code here for future reference | ||
// await queryRunner.query(`INSERT INTO "IBF-app"."point-data" | ||
// ("pointDataId", "countryCodeISO3", "pointDataCategory", "attributes", geom, "referenceId") | ||
// select id | ||
// ,"countryCodeISO3" | ||
// ,'glofas_stations' | ||
// ,(cast('{"stationName":"' as varchar) || "stationName" || cast('","stationCode":"' || "stationCode" || '"}' as varchar))::json | ||
// ,geom | ||
// ,null | ||
// from "IBF-app"."glofas-station" `); | ||
|
||
// await queryRunner.query(`INSERT INTO "IBF-app"."dynamic-point-data" | ||
// ("dynamicPointDataId", "timestamp", "key", value, "pointPointDataId") | ||
// select uuid_generate_v4() | ||
// ,date | ||
// ,unnest(array['forecastLevel','forecastReturnPeriod','triggerLevel','eapAlertClass']) as key | ||
// ,unnest(array[cast("forecastLevel" as varchar),cast("forecastReturnPeriod" as varchar),cast("triggerLevel" as varchar),"eapAlertClass"]) as value | ||
// ,"glofasStationId" | ||
// from "IBF-app"."glofas-station-forecast" gsf `); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "IBF-app"."dynamic-point-data" DROP CONSTRAINT "FK_289a1f52e25e270d9a28bd9d35a"`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "IBF-app"."dynamic-point-data" DROP CONSTRAINT "FK_9aaa9be5dbe82b610209bcb456b"`, | ||
); | ||
await queryRunner.query(`DROP TABLE "IBF-app"."dynamic-point-data"`); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...rvice/src/api/point-data/dto/example/MWI/flash-floods/dynamic-point-data_water-level.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"fid": 1, | ||
"value": 100 | ||
}, | ||
{ | ||
"fid": 2, | ||
"value": 100 | ||
}, | ||
{ | ||
"fid": 3, | ||
"value": 100 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
services/API-service/src/api/point-data/dto/upload-gauge.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { IsNotEmpty, IsOptional, IsString } from 'class-validator'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class GaugeDto { | ||
@ApiProperty({ example: 'name' }) | ||
@IsString() | ||
public name: string = undefined; | ||
|
||
@ApiProperty({ example: 1234 }) | ||
@IsOptional() | ||
public fid: number = undefined; | ||
|
||
@ApiProperty({ example: 0 }) | ||
@IsNotEmpty() | ||
public lat: number; | ||
|
||
@ApiProperty({ example: 0 }) | ||
@IsNotEmpty() | ||
public lon: number; | ||
} |
34 changes: 34 additions & 0 deletions
34
services/API-service/src/api/point-data/dynamic-point-data.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
Entity, | ||
PrimaryGeneratedColumn, | ||
Column, | ||
ManyToOne, | ||
JoinColumn, | ||
} from 'typeorm'; | ||
import { PointDataEntity } from './point-data.entity'; | ||
import { LeadTimeEntity } from '../lead-time/lead-time.entity'; | ||
|
||
@Entity('dynamic-point-data') | ||
export class DynamicPointDataEntity { | ||
@PrimaryGeneratedColumn('uuid') | ||
public dynamicPointDataId: string; | ||
|
||
@ManyToOne( | ||
(): typeof PointDataEntity => PointDataEntity, | ||
(point): DynamicPointDataEntity[] => point.dynamicData, | ||
) | ||
public point: PointDataEntity; | ||
|
||
@ManyToOne((): typeof LeadTimeEntity => LeadTimeEntity) | ||
@JoinColumn({ name: 'leadTime', referencedColumnName: 'leadTimeName' }) | ||
public leadTime: string; | ||
|
||
@Column({ type: 'timestamp' }) | ||
public timestamp: Date; | ||
|
||
@Column() | ||
public key: string; | ||
|
||
@Column({ nullable: true }) | ||
public value: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
services/API-service/src/scripts/git-lfs/standard-point-layers/gauges_MWI.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
id,fid,name,Country,lat,lon | ||
1,1,Kariba,MWI,-9.940606036,33.92438203 | ||
2,2,Tugwi Mukosi,MWI,-9.938750283,33.92635764 | ||
3,3,Mutirikwi,MWI,-11.89861174,33.59389079 |
Oops, something went wrong.