fix undefined error (#337)

* fix undefined error

* git status
This commit is contained in:
saml33 2022-07-02 22:35:16 +10:00 committed by GitHub
parent c919d87696
commit bc2539ef51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -41,14 +41,14 @@ const getAverageStats = (
const oldestStat = timeFilteredStats[0]
const latestStat = timeFilteredStats[timeFilteredStats.length - 1]
let avg
if (type in latestStat && type in oldestStat) {
if (latestStat && oldestStat && type in latestStat && type in oldestStat) {
avg =
Math.pow(latestStat[type] / oldestStat[type], 365 / daysAgo) * 100 - 100
}
priorDate.setHours(priorDate.getHours() + 1)
if (new Date(oldestStat.hourly).getDate() > priorDate.getDate()) {
if (new Date(oldestStat?.hourly).getDate() > priorDate.getDate()) {
return '-'
}
if (avg) {