Skip to content

Commit 427050c

Browse files
committed
Fix ranges issue
1 parent dfb46d3 commit 427050c

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/Cache.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,18 @@ async function fetchSingleRange(
6262
list.push(dup);
6363
return {
6464
entityId: entityIdWithAttribute,
65-
range: [
66-
startT,
67-
+new Date(last.last_updated),
68-
], // cap range to now
65+
range: [startT, +new Date(dup.last_updated)], // cap range to now
6966
attributes: {
7067
unit_of_measurement: "",
7168
...list[0].attributes,
7269
},
73-
history: list.map((entry) => ({
74-
...entry,
75-
state: attribute ? entry.attributes[attribute] : entry.state,
76-
last_updated: +new Date(entry.last_updated || entry.last_changed),
77-
})),
70+
history: list
71+
.map((entry) => ({
72+
...entry,
73+
state: attribute ? entry.attributes[attribute] : entry.state,
74+
last_updated: +new Date(entry.last_updated || entry.last_changed),
75+
}))
76+
.filter(({ last_updated }) => last_updated),
7877
};
7978
}
8079
export default class Cache {

0 commit comments

Comments
 (0)