Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #1092 for deleting measurements, as well #1303

Merged
merged 2 commits into from
Jan 3, 2025
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
2 changes: 2 additions & 0 deletions documentation/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Infrastructure / Support
Bugfixes
-----------
* Fix table sorting on the assets, accounts and users page (regression from `PR #988 <https://github.com/FlexMeasures/flexmeasures/pull/988>`_) [see `PR #1239 <https://github.com/FlexMeasures/flexmeasures/pull/1239>`_, `PR #1242 <https://github.com/FlexMeasures/flexmeasures/pull/1242>`_, `PR #1248 <https://github.com/FlexMeasures/flexmeasures/pull/1248>`_, `PR #1247 <https://github.com/FlexMeasures/flexmeasures/pull/1247>`_ and `PR #1272 <https://github.com/FlexMeasures/flexmeasures/pull/1272>`_]
* Fix `flexmeasures delete measurements` and `flexmeasures delete prognoses` which had an error in counting affected rows after SQLAlchemy2.0 upgrade [see `PR #1095 <https://github.com/FlexMeasures/flexmeasures/pull/1095>`_ and `PR #1303 <https://github.com/FlexMeasures/flexmeasures/pull/1303>`_]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-urgent friendly reminder: rst syntax uses double slanted quotes.


* Fix asset count on the user page, which showed 0 assets after (de)activating a user or resetting their password [see `PR #1251 <https://github.com/FlexMeasures/flexmeasures/pull/1251>`_]
* The UI footer now stays at the bottom even on pages with little content [see `PR #1204 <https://github.com/FlexMeasures/flexmeasures/pull/1204>`_]
* Correct stroke dash (based on source type) for forecasts made by forecasters included in FlexMeasures [see `PR #1211 <https://www.github.com/FlexMeasures/flexmeasures/pull/1211>`_]
Expand Down
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
Loading