MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / insert_turn

Method insert_turn

src/global_db.rs:3687–3712  ·  view source on GitHub ↗

Insert a parsed turn. Returns `true` if inserted, `false` if duplicate.

(&self, turn: &crate::types::CostTurn)

Source from the content-addressed store, hash-verified

3685
3686 /// Insert a parsed turn. Returns `true` if inserted, `false` if duplicate.
3687 pub async fn insert_turn(&self, turn: &crate::types::CostTurn) -> bool {
3688 self.conn
3689 .execute(
3690 "INSERT OR IGNORE INTO turns
3691 (message_id, project_hash, session_id, model, timestamp,
3692 input_tokens, output_tokens, cache_write_tokens, cache_read_tokens,
3693 cost_usd, category, tool_names)
3694 VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12)",
3695 params![
3696 turn.message_id.clone(),
3697 turn.project_hash.clone(),
3698 turn.session_id.clone(),
3699 turn.model.clone(),
3700 turn.timestamp as i64,
3701 turn.input_tokens as i64,
3702 turn.output_tokens as i64,
3703 turn.cache_write_tokens as i64,
3704 turn.cache_read_tokens as i64,
3705 turn.cost_usd,
3706 turn.category.clone(),
3707 turn.tool_names.clone(),
3708 ],
3709 )
3710 .await
3711 .is_ok_and(|n| n > 0)
3712 }
3713
3714 /// Insert parsed turns in one transaction, returning the number of new rows.
3715 pub async fn insert_turns(&self, turns: &[crate::types::CostTurn]) -> usize {

Callers 1

ingestFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected