Skip to content

Commit

Permalink
Merge pull request #571 from rodekruis/feat.glofas_api
Browse files Browse the repository at this point in the history
fix: fix seed comma error AB#6543
  • Loading branch information
jannisvisser authored Mar 15, 2021
2 parents a75440d + 8868bc6 commit 5498763
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class GlofasStationEntity {
@Column()
public stationCode: string;

@Column()
@Column({ nullable: true })
public stationName: string;

@Column({ nullable: true, type: 'real' })
Expand All @@ -29,6 +29,6 @@ export class GlofasStationEntity {
@Column({ nullable: true, type: 'real' })
public threshold20Year: string;

@Column()
@Column({ nullable: true })
public geom: string;
}
4 changes: 1 addition & 3 deletions services/API-service/src/scripts/seed-glofas-station.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ export class SeedGlofasStation implements InterfaceScript {
stationCode: station['station_code'],
stationName: station['station_name'],
triggerLevel:
station[country.glofasStationInput['triggerColName']] == ''
? null
: station[country.glofasStationInput['triggerColName']],
station[country.glofasStationInput['triggerColName']],
threshold2Year: station['2yr_threshold'],
threshold5Year: station['5yr_threshold'],
threshold10Year: station['10yr_threshold'],
Expand Down
7 changes: 6 additions & 1 deletion services/API-service/src/scripts/seed-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ export class SeedHelper {
stream
.pipe(csv({ separator: separator }))
.on('error', (error): void => reject(error))
.on('data', (row): number => parsedData.push(row))
.on('data', (row): number => {
Object.keys(row).forEach(key =>
row[key] === '' ? (row[key] = null) : row[key],
);
return parsedData.push(row);
})
.on('end', (): void => {
resolve(parsedData);
});
Expand Down

0 comments on commit 5498763

Please sign in to comment.