Initial MVP commit
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:
81
internal/adapters/postgres/queries.go
Normal file
81
internal/adapters/postgres/queries.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package postgres
|
||||
|
||||
const (
|
||||
queryObservationSummary = `
|
||||
SELECT
|
||||
AVG(temperature_c) AS temperature_c,
|
||||
AVG(apparent_temperature_c) AS apparent_temperature_c
|
||||
FROM observations
|
||||
WHERE observed_at > CURRENT_TIMESTAMP - make_interval(mins => $1);
|
||||
`
|
||||
|
||||
queryObservationConditions = `
|
||||
SELECT
|
||||
station_id,
|
||||
observed_at,
|
||||
temperature_c,
|
||||
text_description,
|
||||
provider_raw_description,
|
||||
condition_text
|
||||
FROM observations
|
||||
WHERE observed_at > CURRENT_TIMESTAMP - make_interval(mins => $1)
|
||||
ORDER BY observed_at DESC;
|
||||
`
|
||||
|
||||
queryObservationPrecipitation = `
|
||||
SELECT
|
||||
raw_text
|
||||
FROM observation_present_weather
|
||||
WHERE observed_at > CURRENT_TIMESTAMP - make_interval(mins => $1)
|
||||
ORDER BY observed_at DESC;
|
||||
`
|
||||
|
||||
queryForecastPeriodsAt = `
|
||||
SELECT
|
||||
period_index,
|
||||
start_time,
|
||||
end_time,
|
||||
name,
|
||||
is_day,
|
||||
condition_code,
|
||||
condition_text,
|
||||
provider_raw_description,
|
||||
text_description,
|
||||
detailed_text,
|
||||
icon_url,
|
||||
temperature_c,
|
||||
temperature_c_min,
|
||||
temperature_c_max,
|
||||
dewpoint_c,
|
||||
relative_humidity_percent,
|
||||
wind_direction_degrees,
|
||||
wind_speed_kmh,
|
||||
wind_gust_kmh,
|
||||
barometric_pressure_pa,
|
||||
visibility_meters,
|
||||
apparent_temperature_c,
|
||||
cloud_cover_percent,
|
||||
probability_of_precipitation_percent,
|
||||
precipitation_amount_mm,
|
||||
snowfall_depth_mm,
|
||||
uv_index
|
||||
FROM forecast_periods
|
||||
WHERE start_time < $1
|
||||
AND end_time > $1
|
||||
ORDER BY period_index ASC, start_time DESC
|
||||
LIMIT $2;
|
||||
`
|
||||
|
||||
queryCurrentAlerts = `
|
||||
SELECT
|
||||
effective,
|
||||
expires,
|
||||
severity,
|
||||
event,
|
||||
headline,
|
||||
instruction,
|
||||
description
|
||||
FROM alerts
|
||||
WHERE expires > CURRENT_TIMESTAMP;
|
||||
`
|
||||
)
|
||||
Reference in New Issue
Block a user