MCPcopy Create free account
hub / github.com/codeaashu/claude-code / deduplicateSessionBranches

Function deduplicateSessionBranches

src/commands/insights.ts:812–829  ·  view source on GitHub ↗
(
  entries: Array<{ log: LogOption; meta: SessionMeta }>,
)

Source from the content-addressed store, hash-verified

810 * (tie-break by longest duration) per session_id.
811 */
812export function deduplicateSessionBranches(
813 entries: Array<{ log: LogOption; meta: SessionMeta }>,
814): Array<{ log: LogOption; meta: SessionMeta }> {
815 const bestBySession = new Map<string, { log: LogOption; meta: SessionMeta }>()
816 for (const entry of entries) {
817 const id = entry.meta.session_id
818 const existing = bestBySession.get(id)
819 if (
820 !existing ||
821 entry.meta.user_message_count > existing.meta.user_message_count ||
822 (entry.meta.user_message_count === existing.meta.user_message_count &&
823 entry.meta.duration_minutes > existing.meta.duration_minutes)
824 ) {
825 bestBySession.set(id, entry)
826 }
827 }
828 return [...bestBySession.values()]
829}
830
831function formatTranscriptForFacets(log: LogOption): string {
832 const lines: string[] = []

Callers

nothing calls this directly

Calls 3

valuesMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected