[Perl] DAQ system for the FAPG.
fix scale gap detection threshold to rollup bucket size
The gap threshold was hardcoded at 30s, which meant that for hourly rollups (weekly/monthly/yearly views), the inter-bucket gap_seconds always exceeded 30s and every point was flagged as a gap — causing all data to render as red dashed gap-fill instead of green trend. Fix: use 2 * rollup_seconds as the gap threshold. A gap is now only flagged when data is missing for more than 2 consecutive rollup periods (e.g. >2 minutes for hourly view, >120s for minute view). Remove the now-unused SERIES_GAP_SECONDS constant.
Changed files
roles/dashboard/lib/FAPG/DAQ/Dashboard/Controller/Reading.pm
@@ -8,7 +8,6 @@
8
8
9
9
my $STATUS_REACHABLE_SECONDS = 120;
10
10
my $MAX_SERIES_RANGE = max_series_range();
11
Removed:
my $SERIES_GAP_SECONDS = 30;
12
11
my $MINUTE_SECONDS = 60;
13
12
my $MAX_SERIES_CACHE_ENTRIES = 256;
14
13
my %SERIES_CACHE;
@@ -90,6 +89,7 @@
90
89
91
90
my $rollup_seconds
92
91
= $window->{bucket_stride} >= 3_600 ? 3_600 : $MINUTE_SECONDS;
92
Added:
my $gap_threshold = 2 * $rollup_seconds;
93
93
my $now = time;
94
94
my $expires_epoch
95
95
= int( $now / $rollup_seconds ) * $rollup_seconds + $rollup_seconds;
@@ -139,8 +139,8 @@
139
139
$rollup_seconds,
140
140
$window->{start_epoch} - ( 2 * $rollup_seconds ),
141
141
$window->{end_epoch},
142
Removed:
$SERIES_GAP_SECONDS,
143
Removed:
$SERIES_GAP_SECONDS,
142
Added:
$gap_threshold,
143
Added:
$gap_threshold,
144
144
)->hashes->to_array;
145
145
146
146
my $points = aggregate_series( $rollups, $window );
roles/dashboard/t/04-readings-series.t
@@ -112,8 +112,8 @@
112
112
my $bucket = minute_floor(time);
113
113
my $db = $t->app->sqlite->db;
114
114
115
Removed:
for my $offset ( 0, 6, 12, 18, 24, 60, 66, 72, 78, 84 ) {
116
Removed:
my $timestamp = utc_timestamp( $bucket - 180 + $offset );
115
Added:
for my $offset ( 0, 6, 12, 18, 24, 180, 186, 192, 198, 204 ) {
116
Added:
my $timestamp = utc_timestamp( $bucket - 300 + $offset );
117
117
118
118
$db->query(
119
119
q{