chore #14740: remove claude config and customer selection
Summaries are not coming to the desktop app, and the customer is chosen in the web UI after the upload: - drop the Anthropic key (Service::Anthropic, Settings field) and delete a leftover keyring entry best-effort at startup - drop the Summary model, the store's summary accessors and the "Zusammenfassung" tab; the transcript is the detail's only content - drop the mocked customer accounts, list_accounts/set_account and the "Kunde" dropdown; calls.account_id and summaries stay in the schema Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+18
-104
@@ -1,5 +1,5 @@
|
||||
//! SQLite-backed persistence for calls, their transcripts, summaries,
|
||||
//! speaker renames and outstanding remote transcription/summary jobs.
|
||||
//! SQLite-backed persistence for calls, their transcripts, speaker renames
|
||||
//! and merges, and outstanding remote transcription jobs.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -10,7 +10,7 @@ use rusqlite::{params, Connection, Row, TransactionBehavior};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::merge::{self, MergeError};
|
||||
use crate::model::{Call, CallId, CallStatus, Segment, Speaker, Summary};
|
||||
use crate::model::{Call, CallId, CallStatus, Segment, Speaker};
|
||||
|
||||
/// Longest call title, in characters.
|
||||
const MAX_TITLE_CHARS: usize = 120;
|
||||
@@ -22,8 +22,8 @@ pub enum StoreError {
|
||||
Sqlite(#[from] rusqlite::Error),
|
||||
|
||||
/// A value read back from SQLite could not be interpreted, e.g. an
|
||||
/// unknown `status` string, invalid RFC 3339 timestamp, unparsable
|
||||
/// speaker key or malformed summary JSON.
|
||||
/// unknown `status` string, invalid RFC 3339 timestamp or unparsable
|
||||
/// speaker key.
|
||||
#[error("corrupt stored value: {0}")]
|
||||
Corrupt(String),
|
||||
|
||||
@@ -51,7 +51,9 @@ pub struct RecoveryReport {
|
||||
pub failed: Vec<CallId>,
|
||||
}
|
||||
|
||||
/// Version 1: the first release.
|
||||
/// Version 1: the first release. `calls.account_id` (the customer mock) and
|
||||
/// `summaries` are no longer used; they stay so no migration has to drop
|
||||
/// them.
|
||||
const SCHEMA_V1_SQL: &str = "
|
||||
CREATE TABLE IF NOT EXISTS calls (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -152,8 +154,8 @@ impl Store {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
conn.execute(
|
||||
"INSERT INTO calls \
|
||||
(app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, account_id) \
|
||||
VALUES (?1, ?2, NULL, ?3, 0, NULL, ?4, ?5, NULL, 0, NULL)",
|
||||
(app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted) \
|
||||
VALUES (?1, ?2, NULL, ?3, 0, NULL, ?4, ?5, NULL, 0)",
|
||||
params![
|
||||
app,
|
||||
dt_to_str(started_at),
|
||||
@@ -271,33 +273,6 @@ impl Store {
|
||||
Ok(segments)
|
||||
}
|
||||
|
||||
pub fn save_summary(&self, id: CallId, summary: &Summary, edited: bool) -> Result<()> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
let json = serde_json::to_string(summary)
|
||||
.map_err(|e| StoreError::Corrupt(format!("failed to serialize summary: {e}")))?;
|
||||
conn.execute(
|
||||
"INSERT INTO summaries (call_id, json, edited) VALUES (?1, ?2, ?3) \
|
||||
ON CONFLICT(call_id) DO UPDATE SET json = excluded.json, edited = excluded.edited",
|
||||
params![id, json, edited],
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn summary(&self, id: CallId) -> Result<Option<Summary>> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
let mut stmt = conn.prepare("SELECT json FROM summaries WHERE call_id = ?1")?;
|
||||
let mut rows = stmt.query(params![id])?;
|
||||
match rows.next()? {
|
||||
Some(row) => {
|
||||
let json: String = row.get(0)?;
|
||||
let summary = serde_json::from_str(&json)
|
||||
.map_err(|e| StoreError::Corrupt(format!("invalid summary json: {e}")))?;
|
||||
Ok(Some(summary))
|
||||
}
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_speaker_name(&self, id: CallId, speaker_key: &str, name: &str) -> Result<()> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
conn.execute(
|
||||
@@ -398,8 +373,9 @@ impl Store {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Deletes a call and every row derived from it (segments, summary,
|
||||
/// speaker names and merges, remote jobs).
|
||||
/// Deletes a call and every row derived from it (segments, speaker
|
||||
/// names and merges, remote jobs; also the `summaries` table of schema
|
||||
/// v1, which nothing writes).
|
||||
pub fn delete_call(&self, id: CallId) -> Result<()> {
|
||||
let mut conn = self.conn.lock().unwrap();
|
||||
let tx = conn.transaction()?;
|
||||
@@ -413,15 +389,6 @@ impl Store {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_account(&self, id: CallId, account_id: Option<&str>) -> Result<()> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
conn.execute(
|
||||
"UPDATE calls SET account_id = ?1 WHERE id = ?2",
|
||||
params![account_id, id],
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn record_remote_job(&self, id: CallId, track: &str, remote_id: &str) -> Result<()> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
conn.execute(
|
||||
@@ -470,7 +437,7 @@ impl Store {
|
||||
/// `AwaitingDecision`, with `interrupted` set and `ended_at` set to now
|
||||
/// if it was not already set (a later pass corrects it from the WAV
|
||||
/// length).
|
||||
/// - `Processing` calls were mid-transcription/summarization: they move
|
||||
/// - `Processing` calls were mid-transcription: they move
|
||||
/// to `Failed` with a fixed error message.
|
||||
///
|
||||
/// Both updates run in a single transaction.
|
||||
@@ -547,9 +514,9 @@ fn ids_with_status(conn: &rusqlite::Connection, status: CallStatus) -> Result<Ve
|
||||
Ok(ids)
|
||||
}
|
||||
|
||||
const SELECT_ALL_CALLS_SQL: &str = "SELECT id, app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, account_id, title FROM calls";
|
||||
const SELECT_ALL_CALLS_SQL: &str = "SELECT id, app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, title FROM calls";
|
||||
|
||||
const SELECT_CALL_COLUMNS_SQL: &str = "SELECT id, app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, account_id, title FROM calls WHERE id = ?1";
|
||||
const SELECT_CALL_COLUMNS_SQL: &str = "SELECT id, app, started_at, ended_at, status, interrupted, error, mic_path, out_path, transcribed_at, audio_deleted, title FROM calls WHERE id = ?1";
|
||||
|
||||
fn row_to_call(row: &Row) -> Result<Call> {
|
||||
let id: CallId = row.get(0)?;
|
||||
@@ -563,8 +530,7 @@ fn row_to_call(row: &Row) -> Result<Call> {
|
||||
let out_path: String = row.get(8)?;
|
||||
let transcribed_at: Option<String> = row.get(9)?;
|
||||
let audio_deleted: bool = row.get(10)?;
|
||||
let account_id: Option<String> = row.get(11)?;
|
||||
let title: Option<String> = row.get(12)?;
|
||||
let title: Option<String> = row.get(11)?;
|
||||
|
||||
Ok(Call {
|
||||
id,
|
||||
@@ -578,7 +544,6 @@ fn row_to_call(row: &Row) -> Result<Call> {
|
||||
out_path: PathBuf::from(out_path),
|
||||
transcribed_at: opt_dt_from_str(transcribed_at)?,
|
||||
audio_deleted,
|
||||
account_id,
|
||||
title,
|
||||
})
|
||||
}
|
||||
@@ -637,9 +602,7 @@ mod tests {
|
||||
|
||||
use chrono::Local;
|
||||
|
||||
use crate::model::{
|
||||
CallId, CallStatus, NaechsterKontakt, Owner, Segment, Speaker, Summary, Todo,
|
||||
};
|
||||
use crate::model::{CallId, CallStatus, Segment, Speaker};
|
||||
use crate::store::Store;
|
||||
|
||||
/// The schema of user_version 1, exactly as the first release created
|
||||
@@ -754,7 +717,6 @@ CREATE TABLE IF NOT EXISTS remote_jobs (
|
||||
let call = store.get_call(1).unwrap().expect("call kept");
|
||||
assert_eq!(call.app, "Microsoft Teams");
|
||||
assert_eq!(call.status, CallStatus::Done);
|
||||
assert_eq!(call.account_id.as_deref(), Some("mock-2"));
|
||||
assert_eq!(call.mic_path, PathBuf::from("/rec/1-mic.wav"));
|
||||
assert_eq!(call.title, None);
|
||||
let texts: Vec<_> = store
|
||||
@@ -939,38 +901,6 @@ CREATE TABLE IF NOT EXISTS remote_jobs (
|
||||
assert_eq!(store.segments(id).unwrap(), second);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn summary_roundtrip_with_null_dates() {
|
||||
let store = Store::open_in_memory().unwrap();
|
||||
let id = store
|
||||
.create_call(
|
||||
"teams.exe",
|
||||
Local::now(),
|
||||
Path::new("/tmp/mic.wav"),
|
||||
Path::new("/tmp/out.wav"),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(store.summary(id).unwrap(), None);
|
||||
|
||||
let summary = Summary {
|
||||
kernpunkte: vec!["Punkt 1".to_string()],
|
||||
vereinbarungen: vec!["Angebot folgt".to_string()],
|
||||
todos: vec![Todo {
|
||||
text: "Angebot schicken".to_string(),
|
||||
owner: Owner::Ich,
|
||||
faellig: None,
|
||||
erledigt: false,
|
||||
}],
|
||||
naechster_kontakt: NaechsterKontakt {
|
||||
datum: None,
|
||||
notiz: None,
|
||||
},
|
||||
};
|
||||
store.save_summary(id, &summary, false).unwrap();
|
||||
assert_eq!(store.summary(id).unwrap(), Some(summary));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn speaker_names_upsert() {
|
||||
let store = Store::open_in_memory().unwrap();
|
||||
@@ -1167,21 +1097,6 @@ CREATE TABLE IF NOT EXISTS remote_jobs (
|
||||
}],
|
||||
)
|
||||
.unwrap();
|
||||
store
|
||||
.save_summary(
|
||||
id,
|
||||
&Summary {
|
||||
kernpunkte: vec![],
|
||||
vereinbarungen: vec![],
|
||||
todos: vec![],
|
||||
naechster_kontakt: NaechsterKontakt {
|
||||
datum: None,
|
||||
notiz: None,
|
||||
},
|
||||
},
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
store.set_speaker_name(id, "me", "Ich").unwrap();
|
||||
store.set_speaker_merge(id, "remote:2", "remote:1").unwrap();
|
||||
store
|
||||
@@ -1192,7 +1107,6 @@ CREATE TABLE IF NOT EXISTS remote_jobs (
|
||||
|
||||
assert_eq!(store.get_call(id).unwrap(), None);
|
||||
assert_eq!(store.segments(id).unwrap(), Vec::new());
|
||||
assert_eq!(store.summary(id).unwrap(), None);
|
||||
assert_eq!(store.speaker_names(id).unwrap(), BTreeMap::new());
|
||||
assert_eq!(store.remote_jobs(id).unwrap(), Vec::new());
|
||||
assert_eq!(store.speaker_merges(id).unwrap(), BTreeMap::new());
|
||||
|
||||
Reference in New Issue
Block a user