MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / create

Method create

crates/opencode-storage/src/repository.rs:113–193  ·  view source on GitHub ↗
(&self, session: &Session)

Source from the content-addressed store, hash-verified

111 }
112
113 pub async fn create(&self, session: &Session) -> Result<(), DatabaseError> {
114 let summary_diffs = session
115 .summary
116 .as_ref()
117 .and_then(|s| serde_json::to_string(&s.diffs).ok());
118
119 let revert_json = session
120 .revert
121 .as_ref()
122 .and_then(|r| serde_json::to_string(r).ok());
123
124 let permission_json = session
125 .permission
126 .as_ref()
127 .and_then(|p| serde_json::to_string(p).ok());
128
129 let share_url = session.share.as_ref().map(|s| s.url.as_str());
130
131 let usage = session.usage.as_ref();
132
133 sqlx::query(
134 r#"
135 INSERT INTO sessions (
136 id, project_id, parent_id, slug, directory, title, version, share_url,
137 summary_additions, summary_deletions, summary_files, summary_diffs,
138 revert, permission,
139 usage_input_tokens, usage_output_tokens, usage_reasoning_tokens,
140 usage_cache_write_tokens, usage_cache_read_tokens, usage_total_cost,
141 status, created_at, updated_at, time_compacting, time_archived
142 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
143 "#,
144 )
145 .bind(&session.id)
146 .bind(&session.project_id)
147 .bind(&session.parent_id)
148 .bind(&session.slug)
149 .bind(&session.directory)
150 .bind(&session.title)
151 .bind(&session.version)
152 .bind(share_url)
153 .bind(
154 session
155 .summary
156 .as_ref()
157 .map(|s| s.additions as i64)
158 .unwrap_or(0),
159 )
160 .bind(
161 session
162 .summary
163 .as_ref()
164 .map(|s| s.deletions as i64)
165 .unwrap_or(0),
166 )
167 .bind(
168 session
169 .summary
170 .as_ref()

Callers

nothing calls this directly

Calls 3

status_to_stringFunction · 0.85
as_strMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected