feat: add tag_dao to InsightGenerator for tag-based context enrichment

Threads SqliteTagDao through InsightGenerator and AppState (both default
and test_state). Adds Send+Sync bounds to TagDao trait with unsafe impls
for SqliteTagDao (always Mutex-protected) and TestTagDao (single-threaded).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cameron
2026-03-18 16:59:39 -04:00
parent b31b4b903c
commit 387ce23afd
3 changed files with 20 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ use crate::database::{
SqliteLocationHistoryDao, SqliteSearchHistoryDao,
};
use crate::database::{PreviewDao, SqlitePreviewDao};
use crate::tags::{SqliteTagDao, TagDao};
use crate::video::actors::{
PlaylistGenerator, PreviewClipGenerator, StreamActor, VideoPlaylistManager,
};
@@ -119,6 +120,8 @@ impl Default for AppState {
Arc::new(Mutex::new(Box::new(SqliteLocationHistoryDao::new())));
let search_dao: Arc<Mutex<Box<dyn SearchHistoryDao>>> =
Arc::new(Mutex::new(Box::new(SqliteSearchHistoryDao::new())));
let tag_dao: Arc<Mutex<Box<dyn TagDao>>> =
Arc::new(Mutex::new(Box::new(SqliteTagDao::default())));
// Load base path
let base_path = env::var("BASE_PATH").expect("BASE_PATH was not set in the env");
@@ -133,6 +136,7 @@ impl Default for AppState {
calendar_dao.clone(),
location_dao.clone(),
search_dao.clone(),
tag_dao.clone(),
base_path.clone(),
);
@@ -196,6 +200,8 @@ impl AppState {
Arc::new(Mutex::new(Box::new(SqliteLocationHistoryDao::new())));
let search_dao: Arc<Mutex<Box<dyn SearchHistoryDao>>> =
Arc::new(Mutex::new(Box::new(SqliteSearchHistoryDao::new())));
let tag_dao: Arc<Mutex<Box<dyn TagDao>>> =
Arc::new(Mutex::new(Box::new(SqliteTagDao::default())));
// Initialize test InsightGenerator with all data sources
let base_path_str = base_path.to_string_lossy().to_string();
@@ -208,6 +214,7 @@ impl AppState {
calendar_dao.clone(),
location_dao.clone(),
search_dao.clone(),
tag_dao.clone(),
base_path_str.clone(),
);