Skip to content

Commit

Permalink
fix: prevent histogram render error on initial no data state
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Janis committed Nov 22, 2020
1 parent a3c928b commit 5a086f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/monitorHistogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function MonitorHistogram({ monitorId, kvMonitor }) {
<span className="font-semibold text-sm">
{dayInHistogramLabel}
</span>
{kvMonitor.checks.hasOwnProperty(dayInHistogram) &&
{kvMonitor && kvMonitor.checks.hasOwnProperty(dayInHistogram) &&
Object.keys(kvMonitor.checks[dayInHistogram].res).map((key) => {
return (
<>
Expand Down
8 changes: 5 additions & 3 deletions src/functions/helpers.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import config from '../../config.yaml'
import { useEffect, useState } from 'react'

const kvDataKey = 'monitors_data_v1_1'

export async function getKVMonitors() {
// trying both to see performance difference
return KV_STATUS_PAGE.get('monitors_data', 'json')
//return JSON.parse(await KV_STATUS_PAGE.get('monitors_data', 'text'))
return KV_STATUS_PAGE.get(kvDataKey, 'json')
//return JSON.parse(await KV_STATUS_PAGE.get(kvDataKey, 'text'))
}

export async function setKVMonitors(data) {
return setKV('monitors_data', JSON.stringify(data))
return setKV(kvDataKey, JSON.stringify(data))
}

export async function setKV(key, value, metadata, expirationTtl) {
Expand Down

0 comments on commit 5a086f5

Please sign in to comment.