(entries: ConsoleEntry[])
| 298 | * Applies workflow-level trimming while preserving newest-first order. |
| 299 | */ |
| 300 | export function trimConsoleEntries(entries: ConsoleEntry[]): ConsoleEntry[] { |
| 301 | const workflowGroups = new Map<string, ConsoleEntry[]>() |
| 302 | |
| 303 | for (const entry of entries) { |
| 304 | const workflowEntries = workflowGroups.get(entry.workflowId) |
| 305 | if (workflowEntries) { |
| 306 | workflowEntries.push(entry) |
| 307 | } else { |
| 308 | workflowGroups.set(entry.workflowId, [entry]) |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | const keptEntryIds = new Set<string>() |
| 313 | |
| 314 | for (const workflowEntries of workflowGroups.values()) { |
| 315 | trimWorkflowConsoleEntries(workflowEntries).forEach((entry) => keptEntryIds.add(entry.id)) |
| 316 | } |
| 317 | |
| 318 | return entries.filter((entry) => keptEntryIds.has(entry.id)) |
| 319 | } |
no test coverage detected