MCPcopy Create free account
hub / github.com/ccusage/ccusage / dedup_key

Function dedup_key

rust/crates/ccusage/src/adapter/codebuff/parser.rs:345–365  ·  view source on GitHub ↗
(
    message: &serde_json::Map<String, Value>,
    session_id: &str,
    timestamp: crate::TimestampMs,
    model: &str,
    usage: &AssistantUsage,
    ordinal: usize,
)

Source from the content-addressed store, hash-verified

343}
344
345fn dedup_key(
346 message: &serde_json::Map<String, Value>,
347 session_id: &str,
348 timestamp: crate::TimestampMs,
349 model: &str,
350 usage: &AssistantUsage,
351 ordinal: usize,
352) -> String {
353 if let Some(id) = string_field(message, "id") {
354 return format!("codebuff:{session_id}:{id}");
355 }
356 format!(
357 "codebuff:{session_id}:{}:{model}:{ordinal}:{}:{}:{}:{}:{}",
358 format_rfc3339_millis(timestamp),
359 usage.input_tokens,
360 usage.output_tokens,
361 usage.cache_read_input_tokens,
362 usage.cache_creation_input_tokens,
363 usage.extra_total_tokens
364 )
365}
366
367fn infer_provider(model: &str) -> &'static str {
368 let model = model.to_ascii_lowercase();

Callers 1

load_chat_fileFunction · 0.85

Calls 1

string_fieldFunction · 0.70

Tested by

no test coverage detected