|
|
|
|
@ -18,6 +18,7 @@ struct SettingsRow {
|
|
|
|
|
categories: serde_json::Value,
|
|
|
|
|
max_items_per_category: i32,
|
|
|
|
|
max_articles_per_source: i32,
|
|
|
|
|
max_links_per_source: i32,
|
|
|
|
|
use_brave_search: bool,
|
|
|
|
|
article_history_days: i32,
|
|
|
|
|
batch_size: i32,
|
|
|
|
|
@ -47,6 +48,7 @@ impl TryFrom<SettingsRow> for UserSettings {
|
|
|
|
|
categories,
|
|
|
|
|
max_items_per_category: row.max_items_per_category,
|
|
|
|
|
max_articles_per_source: row.max_articles_per_source,
|
|
|
|
|
max_links_per_source: row.max_links_per_source,
|
|
|
|
|
use_brave_search: row.use_brave_search,
|
|
|
|
|
article_history_days: row.article_history_days,
|
|
|
|
|
batch_size: row.batch_size,
|
|
|
|
|
@ -78,10 +80,10 @@ pub async fn get_or_create_default(
|
|
|
|
|
|
|
|
|
|
let row = sqlx::query_as::<_, SettingsRow>(
|
|
|
|
|
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_brave_search, article_history_days, batch_size, summary_length, source_extraction_window)
|
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
|
|
|
|
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, max_links_per_source, use_brave_search, article_history_days, batch_size, summary_length, source_extraction_window)
|
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18)
|
|
|
|
|
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_brave_search, article_history_days, batch_size, summary_length, source_extraction_window, 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, max_links_per_source, use_brave_search, article_history_days, batch_size, summary_length, source_extraction_window, updated_at
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.bind(user_id)
|
|
|
|
|
@ -96,6 +98,7 @@ pub async fn get_or_create_default(
|
|
|
|
|
.bind(defaults.rate_limit_max_requests)
|
|
|
|
|
.bind(defaults.rate_limit_time_window_seconds)
|
|
|
|
|
.bind(defaults.max_articles_per_source)
|
|
|
|
|
.bind(defaults.max_links_per_source)
|
|
|
|
|
.bind(defaults.use_brave_search)
|
|
|
|
|
.bind(defaults.article_history_days)
|
|
|
|
|
.bind(defaults.batch_size)
|
|
|
|
|
@ -119,8 +122,8 @@ pub async fn upsert(
|
|
|
|
|
|
|
|
|
|
let row = sqlx::query_as::<_, SettingsRow>(
|
|
|
|
|
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_brave_search, article_history_days, batch_size, summary_length, source_extraction_window)
|
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
|
|
|
|
|
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, max_links_per_source, use_brave_search, article_history_days, batch_size, summary_length, source_extraction_window)
|
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18)
|
|
|
|
|
ON CONFLICT (user_id) DO UPDATE SET
|
|
|
|
|
theme = EXCLUDED.theme,
|
|
|
|
|
max_age_days = EXCLUDED.max_age_days,
|
|
|
|
|
@ -133,13 +136,14 @@ pub async fn upsert(
|
|
|
|
|
rate_limit_max_requests = EXCLUDED.rate_limit_max_requests,
|
|
|
|
|
rate_limit_time_window_seconds = EXCLUDED.rate_limit_time_window_seconds,
|
|
|
|
|
max_articles_per_source = EXCLUDED.max_articles_per_source,
|
|
|
|
|
max_links_per_source = EXCLUDED.max_links_per_source,
|
|
|
|
|
use_brave_search = EXCLUDED.use_brave_search,
|
|
|
|
|
article_history_days = EXCLUDED.article_history_days,
|
|
|
|
|
batch_size = EXCLUDED.batch_size,
|
|
|
|
|
summary_length = EXCLUDED.summary_length,
|
|
|
|
|
source_extraction_window = EXCLUDED.source_extraction_window,
|
|
|
|
|
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_brave_search, article_history_days, batch_size, summary_length, source_extraction_window, 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, max_links_per_source, use_brave_search, article_history_days, batch_size, summary_length, source_extraction_window, updated_at
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.bind(user_id)
|
|
|
|
|
@ -154,6 +158,7 @@ pub async fn upsert(
|
|
|
|
|
.bind(req.rate_limit_max_requests)
|
|
|
|
|
.bind(req.rate_limit_time_window_seconds)
|
|
|
|
|
.bind(req.max_articles_per_source)
|
|
|
|
|
.bind(req.max_links_per_source)
|
|
|
|
|
.bind(req.use_brave_search)
|
|
|
|
|
.bind(req.article_history_days)
|
|
|
|
|
.bind(req.batch_size)
|
|
|
|
|
|