MCPcopy
hub / github.com/chartbrew/chartbrew / finishEvent

Function finishEvent

server/modules/updateAudit.js:466–509  ·  view source on GitHub ↗
(traceContext, event, status = "success", payload = {})

Source from the content-addressed store, hash-verified

464}
465
466async function finishEvent(traceContext, event, status = "success", payload = {}) {
467 if (!traceContext || !event) {
468 return null;
469 }
470
471 const finishedAt = new Date();
472 const mergedPayload = sanitizePayload({
473 ...(event.payload || {}),
474 ...payload,
475 });
476 const durationMs = getDurationMs(event.startedAt, finishedAt);
477
478 try {
479 if (db.UpdateRunEvent && event.id) {
480 await db.UpdateRunEvent.update({
481 status,
482 finishedAt,
483 durationMs,
484 payload: mergedPayload,
485 }, { where: { id: event.id } });
486 }
487 } catch (error) {
488 emitAuditInternalError("[updateAudit] failed to update event", error);
489 }
490
491 emitStructuredAuditLog("event_finished", {
492 runId: traceContext.runId,
493 traceId: traceContext.traceId,
494 rootTraceId: traceContext.rootTraceId,
495 sequence: event.sequence,
496 stage: event.stage,
497 status,
498 durationMs,
499 payload: mergedPayload,
500 });
501
502 return {
503 ...event,
504 status,
505 finishedAt,
506 durationMs,
507 payload: mergedPayload,
508 };
509}
510
511async function completeRun(traceContext, options = {}) {
512 if (!traceContext) {

Callers 9

runRequestMethod · 0.85
updateChartDataMethod · 0.85
completeRunFunction · 0.85
failRunFunction · 0.85
recordInstantEventFunction · 0.85
completeConnectorAuditFunction · 0.85
failConnectorAuditFunction · 0.85
addDashboardToQueueFunction · 0.85
addChartsToQueueFunction · 0.85

Calls 5

sanitizePayloadFunction · 0.85
getDurationMsFunction · 0.85
emitAuditInternalErrorFunction · 0.85
emitStructuredAuditLogFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected