Skip to content

Commit 2be8f94

Browse files
committed
preload forecast values too
1 parent 002e7b1 commit 2be8f94

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

nowcasting_datamodel/read/read.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,18 @@ def get_all_gsp_ids_latest_forecast(
226226

227227
query = query.filter(ForecastSQL.historic == historic)
228228

229-
if preload_children:
230-
query = query.options(joinedload(ForecastSQL.location))
231-
query = query.options(joinedload(ForecastSQL.model))
232-
query = query.options(joinedload(ForecastSQL.input_data_last_updated))
233-
234229
if start_target_time is not None:
235230
query = filter_query_on_target_time(
236231
query=query, start_target_time=start_target_time, historic=historic
237232
)
238233

234+
if preload_children:
235+
query = query.options(joinedload(ForecastSQL.location))
236+
query = query.options(joinedload(ForecastSQL.model))
237+
query = query.options(joinedload(ForecastSQL.input_data_last_updated))
238+
query = query.options(joinedload(ForecastSQL.forecast_values))
239+
query = query.options(joinedload(ForecastSQL.forecast_values_latest))
240+
239241
query = query.order_by(LocationSQL.gsp_id, desc(ForecastSQL.created_utc))
240242

241243
forecasts = query.populate_existing().all()

0 commit comments

Comments
 (0)