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
29 changes: 12 additions & 17 deletions internal/server/postgres/dataserverimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1560,25 +1560,20 @@ func (s *DataPlatformDataServiceServerImpl) GetForecastAsTimeseries(
Int32("dp.forecaster.id", dbExistingForecaster.ForecasterID).
Str("dp.time_window", fmt.Sprintf("%s - %s", start.Time.String(), end.Time.String())).
Msg("no predictions found")

return nil, status.Errorf(
codes.NotFound,
"No predicted values found for the given location at the given horizon.",
)
} else {
l.Debug().
Str("dp.geometry.uuid", dbSource.GeometryUuid.String()).
Int16("dp.source.type_id", dbSource.SourceTypeID).
Int32("dp.forecaster.id", dbExistingForecaster.ForecasterID).
Int32("dp.predictions.count", int32(len(dbValues))).
Str("dp.predictions.target_period", fmt.Sprintf(
"%s - %s",
dbValues[0].TargetTimeUtc.Time.String(),
dbValues[len(dbValues)-1].TargetTimeUtc.Time.String(),
)).
Msg(fmt.Sprintf("found %d predictions", len(dbValues)))
}

l.Debug().
Str("dp.geometry.uuid", dbSource.GeometryUuid.String()).
Int16("dp.source.type_id", dbSource.SourceTypeID).
Int32("dp.forecaster.id", dbExistingForecaster.ForecasterID).
Int32("dp.predictions.count", int32(len(dbValues))).
Str("dp.predictions.target_period", fmt.Sprintf(
"%s - %s",
dbValues[0].TargetTimeUtc.Time.String(),
dbValues[len(dbValues)-1].TargetTimeUtc.Time.String(),
)).
Msg("found predictions")

values := make([]*pb.GetForecastAsTimeseriesResponse_Value, len(dbValues))
for i, value := range dbValues {
otherStats := make(map[string]float32)
Expand Down
20 changes: 18 additions & 2 deletions internal/server/postgres/dataserverimpl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -923,15 +923,31 @@ func TestGetForecastAsTimeseries(t *testing.T) {
expectErr: false,
},
{
name: "Shouldn't return successfully for horizon 60 mins",
name: "Should return no values for horizon 60 mins",
req: &pb.GetForecastAsTimeseriesRequest{
LocationUuid: siteResp.LocationUuid,
Forecaster: forecasterResp.Forecaster,
EnergySource: pb.EnergySource_ENERGY_SOURCE_SOLAR,
HorizonMins: 60,
TimeWindow: defaultTimeWindow,
},
expectErr: true,
expectedValues: []float32{},
expectErr: false,
},
{
name: "Should return no values for a time window outside of the forecasted values",
req: &pb.GetForecastAsTimeseriesRequest{
LocationUuid: siteResp.LocationUuid,
Forecaster: forecasterResp.Forecaster,
EnergySource: pb.EnergySource_ENERGY_SOURCE_SOLAR,
HorizonMins: 0,
TimeWindow: &pb.TimeWindow{
StartTimestampUtc: timestamppb.New(pivotTime.Add(-time.Hour * 48)),
EndTimestampUtc: timestamppb.New(pivotTime.Add(-time.Hour * 42)),
},
},
expectedValues: []float32{},
expectErr: false,
},
{
name: "Should return all predictions for a specific initialization time",
Expand Down
Loading