(
&self,
project_id: Option<&str>,
limit: i64,
)
| 212 | } |
| 213 | |
| 214 | pub async fn list( |
| 215 | &self, |
| 216 | project_id: Option<&str>, |
| 217 | limit: i64, |
| 218 | ) -> Result<Vec<Session>, DatabaseError> { |
| 219 | let rows = match project_id { |
| 220 | Some(pid) => sqlx::query_as::<_, SessionRow>( |
| 221 | r#"SELECT |
| 222 | id, project_id, parent_id, slug, directory, title, version, share_url, |
| 223 | summary_additions, summary_deletions, summary_files, summary_diffs, |
| 224 | revert, permission, |
| 225 | usage_input_tokens, usage_output_tokens, usage_reasoning_tokens, |
| 226 | usage_cache_write_tokens, usage_cache_read_tokens, usage_total_cost, |
| 227 | status, created_at, updated_at, time_compacting, time_archived |
| 228 | FROM sessions WHERE project_id = ? |
| 229 | ORDER BY updated_at DESC LIMIT ?"#, |
| 230 | ) |
| 231 | .bind(pid) |
| 232 | .bind(limit) |
| 233 | .fetch_all(&self.pool) |
| 234 | .await |
| 235 | .map_err(|e| DatabaseError::QueryError(e.to_string()))?, |
| 236 | None => sqlx::query_as::<_, SessionRow>( |
| 237 | r#"SELECT |
| 238 | id, project_id, parent_id, slug, directory, title, version, share_url, |
| 239 | summary_additions, summary_deletions, summary_files, summary_diffs, |
| 240 | revert, permission, |
| 241 | usage_input_tokens, usage_output_tokens, usage_reasoning_tokens, |
| 242 | usage_cache_write_tokens, usage_cache_read_tokens, usage_total_cost, |
| 243 | status, created_at, updated_at, time_compacting, time_archived |
| 244 | FROM sessions |
| 245 | ORDER BY updated_at DESC LIMIT ?"#, |
| 246 | ) |
| 247 | .bind(limit) |
| 248 | .fetch_all(&self.pool) |
| 249 | .await |
| 250 | .map_err(|e| DatabaseError::QueryError(e.to_string()))?, |
| 251 | }; |
| 252 | |
| 253 | Ok(rows.into_iter().map(|r| r.into_session()).collect()) |
| 254 | } |
| 255 | |
| 256 | pub async fn update(&self, session: &Session) -> Result<(), DatabaseError> { |
| 257 | let summary_diffs = session |
nothing calls this directly
no test coverage detected