diff --git a/src/receipts.mjs b/src/receipts.mjs index 9987588..6db0831 100644 --- a/src/receipts.mjs +++ b/src/receipts.mjs @@ -16,4 +16,4 @@ export function createReceiptStore(db,config=''){ } const escapeHtml=value=>String(value??'').replaceAll('&','&').replaceAll('<','<').replaceAll('>','>').replaceAll('"','"'); -export function renderEventsPage(db){const rows=db.prepare('SELECT * FROM deployment_events ORDER BY occurred_at DESC LIMIT 100').all();const counts=db.prepare('SELECT event_type,result,count(*) count FROM deployment_events GROUP BY event_type,result ORDER BY event_type,result').all();return`operational events · trace
trace

Operational events

Builds say what CI produced. Deployments say what a host actually ran.

${counts.map(x=>`${escapeHtml(x.event_type)} · ${escapeHtml(x.result)}: ${x.count}`).join('')}
${rows.map(row=>{const payload=JSON.parse(row.payload),artifacts=payload.artifacts||[];return`
${escapeHtml(row.project)} · ${escapeHtml(row.event_type)}

${escapeHtml(row.source_commit.slice(0,12))} ${escapeHtml(row.source_branch)} ${row.environment?`· ${escapeHtml(row.environment)}`:''}

${escapeHtml(row.result)}

${escapeHtml(row.occurred_at)} · received ${escapeHtml(row.received_at)}

${artifacts.map(x=>`

${escapeHtml(x.component)} ${escapeHtml(x.digest||'digest unavailable')}

`).join('')}
raw private receipt
${escapeHtml(JSON.stringify(payload,null,2))}
`}).join('')||'

No operational events received yet.

'}
`} +export function renderEventsPage(db){const rows=db.prepare('SELECT * FROM deployment_events ORDER BY occurred_at DESC LIMIT 100').all();const counts=db.prepare('SELECT event_type,result,count(*) count FROM deployment_events GROUP BY event_type,result ORDER BY event_type,result').all();return`operational events · trace
trace

Operational events

Builds say what CI produced. Deployments say what a host actually ran.

${counts.map(x=>`${escapeHtml(x.event_type)} · ${escapeHtml(x.result)}: ${x.count}`).join('')}
${rows.map(row=>{const payload=JSON.parse(row.payload),artifacts=payload.artifacts||[];return`
${escapeHtml(row.project)} · ${escapeHtml(row.event_type)}

${escapeHtml(row.source_commit.slice(0,12))} ${escapeHtml(row.source_branch)} ${row.environment?`· ${escapeHtml(row.environment)}`:''}

${escapeHtml(row.result)}

${escapeHtml(row.occurred_at)} · received ${escapeHtml(row.received_at)}

${artifacts.map(x=>`

${escapeHtml(x.component)} ${escapeHtml(x.digest||'digest unavailable')}

`).join('')}
raw private receipt
${escapeHtml(JSON.stringify(payload,null,2))}
`}).join('')||'

No operational events received yet.

'}
`}