feat: agenda polish, SLA sync, filters
This commit is contained in:
parent
7fb6c65d9a
commit
6ab8a6ce89
40 changed files with 2771 additions and 154 deletions
|
|
@ -21,6 +21,29 @@ function slugify(value) {
|
|||
.replace(/-+/g, "-") || undefined
|
||||
}
|
||||
|
||||
function normalizePrismaSlaSnapshot(snapshot) {
|
||||
if (!snapshot || typeof snapshot !== "object") return undefined
|
||||
const record = snapshot
|
||||
const pauseStatuses =
|
||||
Array.isArray(record.pauseStatuses) && record.pauseStatuses.length > 0
|
||||
? record.pauseStatuses.filter((value) => typeof value === "string")
|
||||
: undefined
|
||||
|
||||
const normalized = {
|
||||
categoryId: typeof record.categoryId === "string" ? record.categoryId : undefined,
|
||||
categoryName: typeof record.categoryName === "string" ? record.categoryName : undefined,
|
||||
priority: typeof record.priority === "string" ? record.priority : undefined,
|
||||
responseTargetMinutes: typeof record.responseTargetMinutes === "number" ? record.responseTargetMinutes : undefined,
|
||||
responseMode: typeof record.responseMode === "string" ? record.responseMode : undefined,
|
||||
solutionTargetMinutes: typeof record.solutionTargetMinutes === "number" ? record.solutionTargetMinutes : undefined,
|
||||
solutionMode: typeof record.solutionMode === "string" ? record.solutionMode : undefined,
|
||||
alertThreshold: typeof record.alertThreshold === "number" ? record.alertThreshold : undefined,
|
||||
pauseStatuses,
|
||||
}
|
||||
|
||||
return Object.values(normalized).some((value) => value !== undefined) ? normalized : undefined
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const tenantId = process.env.SYNC_TENANT_ID || "tenant-atlas"
|
||||
const convexUrl = process.env.NEXT_PUBLIC_CONVEX_URL || "http://127.0.0.1:3210"
|
||||
|
|
@ -103,6 +126,14 @@ async function main() {
|
|||
createdAt: toMillis(ticket.createdAt) ?? Date.now(),
|
||||
updatedAt: toMillis(ticket.updatedAt) ?? Date.now(),
|
||||
tags: Array.isArray(ticket.tags) ? ticket.tags : undefined,
|
||||
slaSnapshot: normalizePrismaSlaSnapshot(ticket.slaSnapshot),
|
||||
slaResponseDueAt: toMillis(ticket.slaResponseDueAt),
|
||||
slaSolutionDueAt: toMillis(ticket.slaSolutionDueAt),
|
||||
slaResponseStatus: ticket.slaResponseStatus ?? undefined,
|
||||
slaSolutionStatus: ticket.slaSolutionStatus ?? undefined,
|
||||
slaPausedAt: toMillis(ticket.slaPausedAt),
|
||||
slaPausedBy: ticket.slaPausedBy ?? undefined,
|
||||
slaPausedMs: typeof ticket.slaPausedMs === "number" ? ticket.slaPausedMs : undefined,
|
||||
comments: ticket.comments.map((comment) => ({
|
||||
authorEmail: comment.author?.email ?? requesterEmail,
|
||||
visibility: comment.visibility,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue