chore(storage): drop dictionary table (v7) + retire unused storage fns — profile_terms is sole surface
This commit is contained in:
@@ -256,62 +256,6 @@ pub async fn search_transcripts(
|
||||
Ok(rows.iter().map(transcript_row_from).collect())
|
||||
}
|
||||
|
||||
// --- Dictionary (custom vocabulary injected into LLM cleanup prompts) ---
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct DictionaryEntry {
|
||||
pub id: i64,
|
||||
pub term: String,
|
||||
pub note: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn list_dictionary(pool: &SqlitePool) -> Result<Vec<DictionaryEntry>> {
|
||||
let rows = sqlx::query("SELECT id, term, note FROM dictionary ORDER BY term ASC")
|
||||
.fetch_all(pool)
|
||||
.await
|
||||
.map_err(|e| KonError::StorageError(format!("List dictionary failed: {e}")))?;
|
||||
Ok(rows
|
||||
.into_iter()
|
||||
.map(|r| DictionaryEntry {
|
||||
id: r.get("id"),
|
||||
term: r.get("term"),
|
||||
note: r.get("note"),
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
pub async fn add_dictionary_entry(
|
||||
pool: &SqlitePool,
|
||||
term: &str,
|
||||
note: Option<&str>,
|
||||
) -> Result<i64> {
|
||||
// ON CONFLICT … DO UPDATE so we always RETURN the actual row id.
|
||||
// The previous `INSERT OR IGNORE` returned 0 (or a stale auto-increment
|
||||
// counter) for duplicate terms, which lied to the frontend about which
|
||||
// row it had just upserted. Bumping `note` to `excluded.note` also lets
|
||||
// the user edit a term's note by re-adding it.
|
||||
let row = sqlx::query(
|
||||
"INSERT INTO dictionary (term, note) VALUES (?, ?) \
|
||||
ON CONFLICT(term) DO UPDATE SET note = excluded.note \
|
||||
RETURNING id",
|
||||
)
|
||||
.bind(term)
|
||||
.bind(note)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
.map_err(|e| KonError::StorageError(format!("Insert dictionary entry failed: {e}")))?;
|
||||
Ok(row.get("id"))
|
||||
}
|
||||
|
||||
pub async fn delete_dictionary_entry(pool: &SqlitePool, id: i64) -> Result<()> {
|
||||
sqlx::query("DELETE FROM dictionary WHERE id = ?")
|
||||
.bind(id)
|
||||
.execute(pool)
|
||||
.await
|
||||
.map_err(|e| KonError::StorageError(format!("Delete dictionary entry failed: {e}")))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// --- Task CRUD ---
|
||||
|
||||
/// Insert a task. `list_id` and `effort` are nullable (schema predates their
|
||||
@@ -780,9 +724,9 @@ pub async fn list_profile_terms(
|
||||
Ok(rows.iter().map(profile_term_row_from).collect())
|
||||
}
|
||||
|
||||
/// UPSERT on UNIQUE(profile_id, term). Mirrors `add_dictionary_entry`'s
|
||||
/// ON CONFLICT … DO UPDATE pattern so that re-adding an existing term
|
||||
/// simply refreshes the note and returns the existing row (not a fresh id).
|
||||
/// UPSERT on UNIQUE(profile_id, term). Uses ON CONFLICT … DO UPDATE so that
|
||||
/// re-adding an existing term simply refreshes the note and returns the
|
||||
/// existing row (not a fresh id).
|
||||
pub async fn add_profile_term(
|
||||
pool: &SqlitePool,
|
||||
profile_id: &str,
|
||||
|
||||
Reference in New Issue
Block a user