MCPcopy Create free account
hub / github.com/Noumena-Network/code / deduplicateLogsBySessionId

Function deduplicateLogsBySessionId

src/utils/sessionStorage.ts:5225–5238  ·  view source on GitHub ↗

* Deduplicates logs by sessionId, keeping the entry with the newest * modified time. Returns sorted logs with sequential value indices.

(logs: LogOption[])

Source from the content-addressed store, hash-verified

5223 * modified time. Returns sorted logs with sequential value indices.
5224 */
5225function deduplicateLogsBySessionId(logs: LogOption[]): LogOption[] {
5226 const deduped = new Map<string, LogOption>()
5227 for (const log of logs) {
5228 if (!log.sessionId) continue
5229 const existing = deduped.get(log.sessionId)
5230 if (!existing || log.modified.getTime() > existing.modified.getTime()) {
5231 deduped.set(log.sessionId, log)
5232 }
5233 }
5234 return sortLogs([...deduped.values()]).map((log, i) => ({
5235 ...log,
5236 value: i,
5237 }))
5238}
5239
5240/**
5241 * Returns lite LogOption[] from pure filesystem metadata (stat only).

Calls 3

sortLogsFunction · 0.85
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected