MCPcopy Create free account
hub / github.com/douglance/devsql / load_todos

Method load_todos

crates/devsql/src/engine.rs:408–454  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

406 }
407
408 fn load_todos(&mut self) -> Result<()> {
409 self.conn.execute(
410 "CREATE TABLE IF NOT EXISTS todos (
411 rowid INTEGER PRIMARY KEY,
412 content TEXT,
413 status TEXT
414 )",
415 [],
416 )?;
417
418 let todos_dir = self.claude_data_dir.join("todos");
419 if !todos_dir.is_dir() {
420 return Ok(());
421 }
422
423 let entries = match std::fs::read_dir(&todos_dir) {
424 Ok(e) => e,
425 Err(_) => return Ok(()),
426 };
427
428 for entry in entries.filter_map(|e| e.ok()) {
429 let path = entry.path();
430 if path.extension().and_then(|e| e.to_str()) != Some("json") {
431 continue;
432 }
433
434 let content = match std::fs::read_to_string(&path) {
435 Ok(c) => c,
436 Err(_) => continue,
437 };
438
439 // Try parsing as a JSON array of todo items
440 if let Ok(items) = serde_json::from_str::<Vec<Value>>(&content) {
441 for item in &items {
442 let todo_content = item.get("content").and_then(|v| v.as_str()).unwrap_or("");
443 let status = item.get("status").and_then(|v| v.as_str()).unwrap_or("");
444
445 self.conn.execute(
446 "INSERT INTO todos (content, status) VALUES (?1, ?2)",
447 params![todo_content, status],
448 )?;
449 }
450 }
451 }
452
453 Ok(())
454 }
455
456 fn load_commits(&mut self) -> Result<()> {
457 self.conn.execute(

Callers 1

load_claude_tablesMethod · 0.80

Calls 2

pathMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected