|
|
|
@ -22,6 +22,7 @@ struct SettingsRow {
|
|
|
|
use_brave_search: bool,
|
|
|
|
use_brave_search: bool,
|
|
|
|
article_history_days: i32,
|
|
|
|
article_history_days: i32,
|
|
|
|
batch_size: i32,
|
|
|
|
batch_size: i32,
|
|
|
|
|
|
|
|
summary_length: i32,
|
|
|
|
search_agent_behavior: String,
|
|
|
|
search_agent_behavior: String,
|
|
|
|
ai_provider: String,
|
|
|
|
ai_provider: String,
|
|
|
|
ai_model: String,
|
|
|
|
ai_model: String,
|
|
|
|
@ -50,6 +51,7 @@ impl TryFrom<SettingsRow> for UserSettings {
|
|
|
|
use_brave_search: row.use_brave_search,
|
|
|
|
use_brave_search: row.use_brave_search,
|
|
|
|
article_history_days: row.article_history_days,
|
|
|
|
article_history_days: row.article_history_days,
|
|
|
|
batch_size: row.batch_size,
|
|
|
|
batch_size: row.batch_size,
|
|
|
|
|
|
|
|
summary_length: row.summary_length,
|
|
|
|
search_agent_behavior: row.search_agent_behavior,
|
|
|
|
search_agent_behavior: row.search_agent_behavior,
|
|
|
|
ai_provider: row.ai_provider,
|
|
|
|
ai_provider: row.ai_provider,
|
|
|
|
ai_model: row.ai_model,
|
|
|
|
ai_model: row.ai_model,
|
|
|
|
@ -76,10 +78,10 @@ pub async fn get_or_create_default(
|
|
|
|
|
|
|
|
|
|
|
|
let row = sqlx::query_as::<_, SettingsRow>(
|
|
|
|
let row = sqlx::query_as::<_, SettingsRow>(
|
|
|
|
r#"
|
|
|
|
r#"
|
|
|
|
INSERT INTO settings (user_id, theme, max_age_days, categories, max_items_per_category, search_agent_behavior, ai_provider, ai_model, ai_model_websearch, rate_limit_max_requests, rate_limit_time_window_seconds, max_articles_per_source, use_llm_for_source_links, use_brave_search, article_history_days, batch_size)
|
|
|
|
INSERT INTO settings (user_id, theme, max_age_days, categories, max_items_per_category, search_agent_behavior, ai_provider, ai_model, ai_model_websearch, rate_limit_max_requests, rate_limit_time_window_seconds, max_articles_per_source, use_llm_for_source_links, use_brave_search, article_history_days, batch_size, summary_length)
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
|
|
|
ON CONFLICT (user_id) DO UPDATE SET user_id = settings.user_id
|
|
|
|
ON CONFLICT (user_id) DO UPDATE SET user_id = settings.user_id
|
|
|
|
RETURNING user_id, theme, max_age_days, categories, max_items_per_category, search_agent_behavior, ai_provider, ai_model, ai_model_websearch, rate_limit_max_requests, rate_limit_time_window_seconds, max_articles_per_source, use_llm_for_source_links, use_brave_search, article_history_days, batch_size, updated_at
|
|
|
|
RETURNING user_id, theme, max_age_days, categories, max_items_per_category, search_agent_behavior, ai_provider, ai_model, ai_model_websearch, rate_limit_max_requests, rate_limit_time_window_seconds, max_articles_per_source, use_llm_for_source_links, use_brave_search, article_history_days, batch_size, summary_length, updated_at
|
|
|
|
"#,
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.bind(user_id)
|
|
|
|
.bind(user_id)
|
|
|
|
@ -98,6 +100,7 @@ pub async fn get_or_create_default(
|
|
|
|
.bind(defaults.use_brave_search)
|
|
|
|
.bind(defaults.use_brave_search)
|
|
|
|
.bind(defaults.article_history_days)
|
|
|
|
.bind(defaults.article_history_days)
|
|
|
|
.bind(defaults.batch_size)
|
|
|
|
.bind(defaults.batch_size)
|
|
|
|
|
|
|
|
.bind(defaults.summary_length)
|
|
|
|
.fetch_one(pool)
|
|
|
|
.fetch_one(pool)
|
|
|
|
.await?;
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
|
|
@ -116,8 +119,8 @@ pub async fn upsert(
|
|
|
|
|
|
|
|
|
|
|
|
let row = sqlx::query_as::<_, SettingsRow>(
|
|
|
|
let row = sqlx::query_as::<_, SettingsRow>(
|
|
|
|
r#"
|
|
|
|
r#"
|
|
|
|
INSERT INTO settings (user_id, theme, max_age_days, categories, max_items_per_category, search_agent_behavior, ai_provider, ai_model, ai_model_websearch, rate_limit_max_requests, rate_limit_time_window_seconds, max_articles_per_source, use_llm_for_source_links, use_brave_search, article_history_days, batch_size)
|
|
|
|
INSERT INTO settings (user_id, theme, max_age_days, categories, max_items_per_category, search_agent_behavior, ai_provider, ai_model, ai_model_websearch, rate_limit_max_requests, rate_limit_time_window_seconds, max_articles_per_source, use_llm_for_source_links, use_brave_search, article_history_days, batch_size, summary_length)
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
|
|
|
ON CONFLICT (user_id) DO UPDATE SET
|
|
|
|
ON CONFLICT (user_id) DO UPDATE SET
|
|
|
|
theme = EXCLUDED.theme,
|
|
|
|
theme = EXCLUDED.theme,
|
|
|
|
max_age_days = EXCLUDED.max_age_days,
|
|
|
|
max_age_days = EXCLUDED.max_age_days,
|
|
|
|
@ -134,8 +137,9 @@ pub async fn upsert(
|
|
|
|
use_brave_search = EXCLUDED.use_brave_search,
|
|
|
|
use_brave_search = EXCLUDED.use_brave_search,
|
|
|
|
article_history_days = EXCLUDED.article_history_days,
|
|
|
|
article_history_days = EXCLUDED.article_history_days,
|
|
|
|
batch_size = EXCLUDED.batch_size,
|
|
|
|
batch_size = EXCLUDED.batch_size,
|
|
|
|
|
|
|
|
summary_length = EXCLUDED.summary_length,
|
|
|
|
updated_at = now()
|
|
|
|
updated_at = now()
|
|
|
|
RETURNING user_id, theme, max_age_days, categories, max_items_per_category, search_agent_behavior, ai_provider, ai_model, ai_model_websearch, rate_limit_max_requests, rate_limit_time_window_seconds, max_articles_per_source, use_llm_for_source_links, use_brave_search, article_history_days, batch_size, updated_at
|
|
|
|
RETURNING user_id, theme, max_age_days, categories, max_items_per_category, search_agent_behavior, ai_provider, ai_model, ai_model_websearch, rate_limit_max_requests, rate_limit_time_window_seconds, max_articles_per_source, use_llm_for_source_links, use_brave_search, article_history_days, batch_size, summary_length, updated_at
|
|
|
|
"#,
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.bind(user_id)
|
|
|
|
.bind(user_id)
|
|
|
|
@ -154,6 +158,7 @@ pub async fn upsert(
|
|
|
|
.bind(req.use_brave_search)
|
|
|
|
.bind(req.use_brave_search)
|
|
|
|
.bind(req.article_history_days)
|
|
|
|
.bind(req.article_history_days)
|
|
|
|
.bind(req.batch_size)
|
|
|
|
.bind(req.batch_size)
|
|
|
|
|
|
|
|
.bind(req.summary_length)
|
|
|
|
.fetch_one(pool)
|
|
|
|
.fetch_one(pool)
|
|
|
|
.await?;
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
|
|
|