@ -20,6 +20,7 @@ struct SettingsRow {
max_articles_per_source : i32 ,
use_llm_for_source_links : bool ,
article_history_days : i32 ,
batch_size : i32 ,
search_agent_behavior : String ,
ai_provider : String ,
ai_model : String ,
@ -46,6 +47,7 @@ impl TryFrom<SettingsRow> for UserSettings {
max_articles_per_source : row . max_articles_per_source ,
use_llm_for_source_links : row . use_llm_for_source_links ,
article_history_days : row . article_history_days ,
batch_size : row . batch_size ,
search_agent_behavior : row . search_agent_behavior ,
ai_provider : row . ai_provider ,
ai_model : row . ai_model ,
@ -72,10 +74,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_llm_for_source_links , article_history_days )
VALUES ( $ 1 , $ 2 , $ 3 , $ 4 , $ 5 , $ 6 , $ 7 , $ 8 , $ 9 , $ 10 , $ 11 , $ 12 , $ 13 , $ 14 )
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 , article_history_days , batch_size )
VALUES ( $ 1 , $ 2 , $ 3 , $ 4 , $ 5 , $ 6 , $ 7 , $ 8 , $ 9 , $ 10 , $ 11 , $ 12 , $ 13 , $ 14 , $ 15 )
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 , article_history_days , 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 , article_history_days , batch_size, updated_at
" #,
)
. bind ( user_id )
@ -92,6 +94,7 @@ pub async fn get_or_create_default(
. bind ( defaults . max_articles_per_source )
. bind ( defaults . use_llm_for_source_links )
. bind ( defaults . article_history_days )
. bind ( defaults . batch_size )
. fetch_one ( pool )
. await ? ;
@ -110,8 +113,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_llm_for_source_links , article_history_days )
VALUES ( $ 1 , $ 2 , $ 3 , $ 4 , $ 5 , $ 6 , $ 7 , $ 8 , $ 9 , $ 10 , $ 11 , $ 12 , $ 13 , $ 14 )
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 , article_history_days , batch_size )
VALUES ( $ 1 , $ 2 , $ 3 , $ 4 , $ 5 , $ 6 , $ 7 , $ 8 , $ 9 , $ 10 , $ 11 , $ 12 , $ 13 , $ 14 , $ 15 )
ON CONFLICT ( user_id ) DO UPDATE SET
theme = EXCLUDED . theme ,
max_age_days = EXCLUDED . max_age_days ,
@ -126,8 +129,9 @@ pub async fn upsert(
max_articles_per_source = EXCLUDED . max_articles_per_source ,
use_llm_for_source_links = EXCLUDED . use_llm_for_source_links ,
article_history_days = EXCLUDED . article_history_days ,
batch_size = EXCLUDED . batch_size ,
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 , article_history_days , 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 , article_history_days , batch_size, updated_at
" #,
)
. bind ( user_id )
@ -144,6 +148,7 @@ pub async fn upsert(
. bind ( req . max_articles_per_source )
. bind ( req . use_llm_for_source_links )
. bind ( req . article_history_days )
. bind ( req . batch_size )
. fetch_one ( pool )
. await ? ;