File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed
src/frequenz/sdk/timeseries/_ringbuffer Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 22
33## Bug Fixes
44
5- - Fix PV power distribution excluding inverters that haven't sent any data since the application started .
5+ - 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 @@ -277,12 +277,12 @@ def test_gaps() -> None: # pylint: disable=too-many-statements
277277 assert buffer .count_covered () == 5
278278 assert len (buffer .gaps ) == 0
279279
280- # whole range gap suffers from sdk#646
280+ # whole range gap
281281 buffer .update (Sample (dt (99 ), None ))
282- assert buffer .oldest_timestamp == dt ( 95 ) # bug: should be None
283- assert buffer .newest_timestamp == dt ( 99 ) # bug: should be None
284- assert buffer .count_valid () == 4 # bug: should be 0 (whole range gap)
285- assert buffer .count_covered () == 5 # bug: should be 0
282+ assert buffer .oldest_timestamp is None
283+ assert buffer .newest_timestamp is None
284+ assert buffer .count_valid () == 0
285+ assert buffer .count_covered () == 0
286286 assert len (buffer .gaps ) == 1
287287
288288
You can’t perform that action at this time.
0 commit comments