Skip to content

Commit 089e95f

Browse files
committed
fix
1 parent 76361ea commit 089e95f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

nowcasting_datamodel/update.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,16 @@ def update_all_forecast_latest(forecasts: List[ForecastSQL], session: Session):
116116
"""
117117

118118
# get all latest forecasts
119-
forecasts_historic = get_latest_forecast_for_gsps(session=session, historic=True)
119+
forecasts_historic_all_gsps = get_latest_forecast_for_gsps(session=session, historic=True)
120120

121121
for forecast in forecasts:
122122

123123
# chose the correct forecast historic
124124
gsp_id = forecast.location.gsp_id
125125
forecast_historic = [
126-
forecast for forecast in forecasts_historic if forecast.location.gsp_id == gsp_id
126+
forecast_historic_one_gsps
127+
for forecast_historic_one_gsps in forecasts_historic_all_gsps
128+
if forecast.location.gsp_id == gsp_id
127129
]
128130
if len(forecast_historic) == 0:
129131
forecast_historic = None

tests/test_update.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ def test_update_one_gsp(db_session):
4444

4545
update_forecast_latest(forecast=forecast_sql, session=db_session)
4646

47+
forecast_values_latest = db_session.query(ForecastValueLatestSQL).all()
4748
assert len(db_session.query(ForecastValueSQL).all()) == 2
48-
assert len(db_session.query(ForecastValueLatestSQL).all()) == 2
49+
assert len(forecast_values_latest) == 2
4950
assert len(db_session.query(ForecastSQL).all()) == 2
51+
assert forecast_values_latest[0].expected_power_generation_megawatts == 2
5052

5153
# new forecast is made
5254
# create and add

0 commit comments

Comments
 (0)