Skip to content

Commit

Permalink
Speed up status page (#1142)
Browse files Browse the repository at this point in the history
* pass most-recent-only=True to get sensor's latest belief

* update docstring
  • Loading branch information
Ahmad-Wahid authored Sep 27, 2024
1 parent 493bd70 commit e62a0cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions documentation/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ New features
Infrastructure / Support
----------------------

* Speed up status page by choosing for a faster query (only latest belief needed) [see `PR #1142 <https://github.com/FlexMeasures/flexmeasures/pull/1142>`_]
* For MacOS developers, install HiGHS solver automatically [see `PR #1187 <https://github.com/FlexMeasures/flexmeasures/pull/1187>`_]

Bugfixes
Expand Down
8 changes: 6 additions & 2 deletions flexmeasures/data/services/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ def get_sensors(


def _get_sensor_bdf(sensor: Sensor, staleness_search: dict) -> BeliefsDataFrame | None:
"""Get bdf for a given sensor with given search parameters."""
"""
Retrieve the BeliefsDataFrame for a given sensor using the specified search parameters. The 'most_recent_only'
parameter is set to True, which ensures that only the most recent belief from the most recent event is returned.
"""
bdf = TimedBelief.search(
sensors=sensor,
most_recent_events_only=True,
most_recent_beliefs_only=False,
most_recent_only=True,
**staleness_search,
)
if bdf.empty:
Expand Down

0 comments on commit e62a0cf

Please sign in to comment.