Skip to content

Commit c98f167

Browse files
committed
Fix extend_to_present with statistics (as pointed out by @FrnchFrgg
1 parent ef1ef39 commit c98f167

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/cache/Cache.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ export default class Cache {
162162
y === "unavailable" || y === "none" || y === "unknown" ? null : y
163163
);
164164
if (entity.extend_to_present && data.xs.length > 0 && entity.offset === 0) {
165+
const last_i = data.xs.length - 1;
165166
data.xs.push(new Date(Date.now() + entity.offset));
166-
data.ys.push(data.ys[data.ys.length - 1]);
167-
data.states.push(data.states[data.states.length - 1]);
167+
data.ys.push(data.ys[last_i]);
168+
if (data.states.length) data.states.push(data.states[last_i]);
169+
if (data.statistics.length) data.statistics.push(data.statistics[last_i]);
168170
}
169171
return data;
170172
}

0 commit comments

Comments
 (0)