Updated the normalized observation schema to remove duplicate and/or unnecessary fields
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
This commit is contained in:
@@ -37,7 +37,7 @@ func mapObservationEvent(e fkevent.Event) ([]fksinks.PostgresWrite, error) {
|
||||
}
|
||||
|
||||
observedAt := obs.Timestamp.UTC()
|
||||
writes := make([]fksinks.PostgresWrite, 0, 1+len(obs.CloudLayers)+len(obs.PresentWeather))
|
||||
writes := make([]fksinks.PostgresWrite, 0, 1+len(obs.PresentWeather))
|
||||
|
||||
writes = append(writes, fksinks.PostgresWrite{
|
||||
Table: tableObservations,
|
||||
@@ -52,39 +52,20 @@ func mapObservationEvent(e fkevent.Event) ([]fksinks.PostgresWrite, error) {
|
||||
"station_name": nullableString(obs.StationName),
|
||||
"observed_at": observedAt,
|
||||
"condition_code": int(obs.ConditionCode),
|
||||
"condition_text": nullableString(obs.ConditionText),
|
||||
"is_day": nullableBool(obs.IsDay),
|
||||
"provider_raw_description": nullableString(obs.ProviderRawDescription),
|
||||
"text_description": nullableString(obs.TextDescription),
|
||||
"icon_url": nullableString(obs.IconURL),
|
||||
"temperature_c": nullableFloat64(obs.TemperatureC),
|
||||
"dewpoint_c": nullableFloat64(obs.DewpointC),
|
||||
"wind_direction_degrees": nullableFloat64(obs.WindDirectionDegrees),
|
||||
"wind_speed_kmh": nullableFloat64(obs.WindSpeedKmh),
|
||||
"wind_gust_kmh": nullableFloat64(obs.WindGustKmh),
|
||||
"barometric_pressure_pa": nullableFloat64(obs.BarometricPressurePa),
|
||||
"sea_level_pressure_pa": nullableFloat64(obs.SeaLevelPressurePa),
|
||||
"visibility_meters": nullableFloat64(obs.VisibilityMeters),
|
||||
"relative_humidity_percent": nullableFloat64(obs.RelativeHumidityPercent),
|
||||
"apparent_temperature_c": nullableFloat64(obs.ApparentTemperatureC),
|
||||
"elevation_meters": nullableFloat64(obs.ElevationMeters),
|
||||
"raw_message": nullableString(obs.RawMessage),
|
||||
},
|
||||
})
|
||||
|
||||
for i, cl := range obs.CloudLayers {
|
||||
writes = append(writes, fksinks.PostgresWrite{
|
||||
Table: tableObservationCloudLayers,
|
||||
Values: map[string]any{
|
||||
"event_id": e.ID,
|
||||
"layer_index": i,
|
||||
"observed_at": observedAt,
|
||||
"base_meters": nullableFloat64(cl.BaseMeters),
|
||||
"amount": nullableString(cl.Amount),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
for i, pw := range obs.PresentWeather {
|
||||
rawText, err := compactJSONText(pw.Raw)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user