MCPcopy
hub / github.com/codeaashu/claude-code / deduplicateLogsBySessionId

Function deduplicateLogsBySessionId

src/utils/sessionStorage.ts:4955–4968  ·  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

4953 * modified time. Returns sorted logs with sequential value indices.
4954 */
4955function deduplicateLogsBySessionId(logs: LogOption[]): LogOption[] {
4956 const deduped = new Map<string, LogOption>()
4957 for (const log of logs) {
4958 if (!log.sessionId) continue
4959 const existing = deduped.get(log.sessionId)
4960 if (!existing || log.modified.getTime() > existing.modified.getTime()) {
4961 deduped.set(log.sessionId, log)
4962 }
4963 }
4964 return sortLogs([...deduped.values()]).map((log, i) => ({
4965 ...log,
4966 value: i,
4967 }))
4968}
4969
4970/**
4971 * Returns lite LogOption[] from pure filesystem metadata (stat only).

Calls 4

sortLogsFunction · 0.85
valuesMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected