flexmeasures
flexmeasures copied to clipboard
Compute `last_value_datetime` using multiple output sensors
Where
flexmeasures.cli.data_add:add_report
What
Currently, the default start time of reports (last_value_datetime
) is being computed using the first sensor in output (taking the max event_start
). Nevertheless, with the introduction of the multiple-output capabilities, this query should take into account all the ouput sensors and return the minimum of the latest event_start
.
This improvement would move the query into its own function and implement some tests.
last_value_datetime = (
db.session.query(func.max(TimedBelief.event_start))
.filter(TimedBelief.sensor_id == output[0]["sensor"].id)
.one_or_none()
)