mirror of
https://github.com/tormachris/cf-workers-status-page.git
synced 2025-07-06 03:52:46 +02:00
feat: optimize KV storage read/write operations
- the state is now stored in a single KV key - there is one write for cron and one read for render
This commit is contained in:
@ -1,17 +1,15 @@
|
||||
import config from '../../config.yaml'
|
||||
|
||||
export default function MonitorStatusHeader({ operational, lastUpdate }) {
|
||||
export default function MonitorStatusHeader({kvMonitorsMetadata}) {
|
||||
let backgroundColor = 'green'
|
||||
let headerText = config.settings.allmonitorsOperational
|
||||
let textColor = 'black'
|
||||
|
||||
if (!operational) {
|
||||
if (!kvMonitorsMetadata.monitorsOperational) {
|
||||
backgroundColor = 'yellow'
|
||||
headerText = config.settings.notAllmonitorsOperational
|
||||
}
|
||||
|
||||
const lastCheckAgo = Math.round((Date.now() - lastUpdate.value) / 1000)
|
||||
|
||||
return (
|
||||
<div className={`ui inverted segment ${backgroundColor}`}>
|
||||
<div className="horizontal flex between">
|
||||
@ -19,9 +17,9 @@ export default function MonitorStatusHeader({ operational, lastUpdate }) {
|
||||
{headerText}
|
||||
</div>
|
||||
{
|
||||
lastUpdate.metadata && typeof window !== 'undefined' && (
|
||||
kvMonitorsMetadata.lastUpdate && typeof window !== 'undefined' && (
|
||||
<div className={`${textColor}-text`}>
|
||||
checked {lastCheckAgo} sec ago (from {lastUpdate.metadata.loc})
|
||||
checked {Math.round((Date.now() - kvMonitorsMetadata.lastUpdate.time) / 1000)} sec ago (from {kvMonitorsMetadata.lastUpdate.loc})
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user