1
0
mirror of https://github.com/tormachris/cf-workers-status-page.git synced 2024-11-23 22:45:43 +01:00

fix: prevent histogram render error on initial no data state

This commit is contained in:
Adam Janis 2020-11-22 13:12:31 +01:00
parent a3c928bb9c
commit 5a086f5ad0
2 changed files with 6 additions and 4 deletions

View File

@ -39,7 +39,7 @@ export default function MonitorHistogram({ monitorId, kvMonitor }) {
<span className="font-semibold text-sm"> <span className="font-semibold text-sm">
{dayInHistogramLabel} {dayInHistogramLabel}
</span> </span>
{kvMonitor.checks.hasOwnProperty(dayInHistogram) && {kvMonitor && kvMonitor.checks.hasOwnProperty(dayInHistogram) &&
Object.keys(kvMonitor.checks[dayInHistogram].res).map((key) => { Object.keys(kvMonitor.checks[dayInHistogram].res).map((key) => {
return ( return (
<> <>

View File

@ -1,14 +1,16 @@
import config from '../../config.yaml' import config from '../../config.yaml'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
const kvDataKey = 'monitors_data_v1_1'
export async function getKVMonitors() { export async function getKVMonitors() {
// trying both to see performance difference // trying both to see performance difference
return KV_STATUS_PAGE.get('monitors_data', 'json') return KV_STATUS_PAGE.get(kvDataKey, 'json')
//return JSON.parse(await KV_STATUS_PAGE.get('monitors_data', 'text')) //return JSON.parse(await KV_STATUS_PAGE.get(kvDataKey, 'text'))
} }
export async function setKVMonitors(data) { 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) { export async function setKV(key, value, metadata, expirationTtl) {