Skip to content

Commit

Permalink
Fix issue #1092 for deleting measurements, as well (1095 handled prog…
Browse files Browse the repository at this point in the history
…noses/forecasts)

Signed-off-by: Nicolas Höning <[email protected]>
  • Loading branch information
nhoening committed Jan 3, 2025
1 parent 604b8d5 commit f85cc45
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions flexmeasures/data/scripts/data_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ def depopulate_measurements(
query = delete(TimedBelief).filter(TimedBelief.belief_horizon <= timedelta(hours=0))
if sensor_id is not None:
query = query.filter(TimedBelief.sensor_id == sensor_id)
num_measurements_deleted = db.session.execute(query)
deletion_result = db.session.execute(query)
num_measurements_deleted = deletion_result.rowcount

click.echo("Deleted %d measurements (ex-post beliefs)" % num_measurements_deleted)

Expand Down Expand Up @@ -346,7 +347,7 @@ def depopulate_prognoses(
query = query.filter(TimedBelief.sensor_id == sensor_id)
deletion_result = db.session.execute(query)
num_forecasts_deleted = deletion_result.rowcount

if not sensor_id:
click.echo("Deleted %d Forecast Jobs" % num_forecasting_jobs_deleted)
click.echo("Deleted %d Schedule Jobs" % num_scheduling_jobs_deleted)
Expand Down

0 comments on commit f85cc45

Please sign in to comment.