Skip to content

Commit

Permalink
refactor: simplify
Browse files Browse the repository at this point in the history
Signed-off-by: F.N. Claessen <felix@seita.nl>
  • Loading branch information
Flix6x committed Feb 16, 2024
1 parent b2f541b commit 8ee173c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions flexmeasures/cli/data_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,14 @@ def delete_beliefs( # noqa: C901
entity_filters = []
if sensors:
entity_filters += [TimedBelief.sensor_id.in_([sensor.id for sensor in sensors])]
select_statement = select(TimedBelief).join(Sensor)
if generic_assets:
entity_filters += [
TimedBelief.sensor_id == Sensor.id,
Sensor.generic_asset_id.in_([asset.id for asset in generic_assets]),
]
select_statement = select(TimedBelief).join(Sensor)

# Create query
q = select_statement.where(*entity_filters, *event_filters)
q = select(TimedBelief).join(Sensor).where(*entity_filters, *event_filters)

# Prompt based on count of query
num_beliefs_up_for_deletion = db.session.scalar(select(func.count()).select_from(q))
Expand Down

0 comments on commit 8ee173c

Please sign in to comment.