File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed
src/frequenz/sdk/timeseries/_ringbuffer Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 5959- Fix the handling of canceled tasks in the data sourcing and resampling actor.
6060- Fix a bug in PV power distribution by excluding inverters that haven't sent any data since startup.
6161- Prevent stacking of power requests to avoid delays in processing when the power request frequency exceeds the processing time.
62+ - Fixes a bug in the ring buffer in case the updated value is missing and creates a gap in time.
Original file line number Diff line number Diff line change @@ -491,8 +491,11 @@ def _update_gaps(
491491 # New missing entry that is not already in a gap?
492492 if record_as_missing :
493493 if not found_in_gaps :
494+ # If there are no gaps and the new value is not subsequent to the
495+ # newest value, we need to start the new gap after the newest value
496+ start_gap = min (newest + self ._sampling_period , timestamp )
494497 self ._gaps .append (
495- Gap (start = timestamp , end = timestamp + self ._sampling_period )
498+ Gap (start = start_gap , end = timestamp + self ._sampling_period )
496499 )
497500 elif len (self ._gaps ) > 0 :
498501 if found_in_gaps :
Original file line number Diff line number Diff line change @@ -275,12 +275,12 @@ def test_gaps() -> None: # pylint: disable=too-many-statements
275275 assert buffer .count_covered () == 5
276276 assert len (buffer .gaps ) == 0
277277
278- # whole range gap suffers from sdk#646
278+ # whole range gap
279279 buffer .update (Sample (dt (99 ), None ))
280- assert buffer .oldest_timestamp == dt ( 95 ) # bug: should be None
281- assert buffer .newest_timestamp == dt ( 99 ) # bug: should be None
282- assert buffer .count_valid () == 4 # bug: should be 0 (whole range gap)
283- assert buffer .count_covered () == 5 # bug: should be 0
280+ assert buffer .oldest_timestamp is None
281+ assert buffer .newest_timestamp is None
282+ assert buffer .count_valid () == 0
283+ assert buffer .count_covered () == 0
284284 assert len (buffer .gaps ) == 1
285285
286286
You can’t perform that action at this time.
0 commit comments