Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/server/postgres/dataserverimpl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,10 +921,10 @@ func TestGetForecastAsTimeseries(t *testing.T) {
}

resp, err := dc.GetForecastAsTimeseries(t.Context(), &pb.GetForecastAsTimeseriesRequest{
LocationUuid: siteResp.LocationUuid,
HorizonMins: uint32(tc.horizonMins),
Forecaster: forecasterResp.Forecaster,
EnergySource: pb.EnergySource_ENERGY_SOURCE_SOLAR,
LocationUuid: siteResp.LocationUuid,
HorizonMins: uint32(tc.horizonMins),
Forecaster: forecasterResp.Forecaster,
EnergySource: pb.EnergySource_ENERGY_SOURCE_SOLAR,
TimeWindow: &pb.TimeWindow{
StartTimestampUtc: timestamppb.New(pivotTime.Add(-time.Hour * 48)),
EndTimestampUtc: timestamppb.New(pivotTime.Add(time.Hour * 36)),
Expand Down
12 changes: 7 additions & 5 deletions internal/server/postgres/sql/queries/predictions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -400,16 +400,18 @@ relevant_predicted_values AS (
deltas AS (
SELECT
rv.geometry_uuid,
rv.source_type_id,
rv.forecast_uuid,
rv.target_time_utc,
rv.horizon_mins,
rv.p50_sip - og.value_sip AS delta_sip
FROM relevant_predicted_values AS rv
LEFT OUTER JOIN obs.observed_generation_values AS og USING (geometry_uuid, source_type_id)
INNER JOIN obs.observed_generation_values AS og
ON rv.geometry_uuid = og.geometry_uuid
AND rv.source_type_id = og.source_type_id
AND rv.target_time_utc = og.observation_timestamp_utc
WHERE
og.observer_uuid = $3
AND og.observation_timestamp_utc = rv.target_time_utc
AND og.geometry_uuid = ANY(sqlc.arg(geometry_uuids)::UUID [])
AND og.observation_timestamp_utc >= sqlc.arg(pivot_timestamp)::TIMESTAMP - INTERVAL '8 days'
AND og.observation_timestamp_utc < sqlc.arg(pivot_timestamp)::TIMESTAMP + INTERVAL '1 millisecond'
)
SELECT
d.geometry_uuid,
Expand Down
Loading