From 85369069c375214be27b2062db04fe740d600c68 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 13 Aug 2026 02:09:58 +0000 Subject: [PATCH] remove remaining dead code left over from /dev endpoints db::ensure_dev_athlete was never called (main.rs had its own, inferior copy, removed in the previous commit). Config::dev_sync_days and Config::require_api_key were only used by the now-removed /dev/sync handlers. --- src/config.rs | 19 ------------------- src/db.rs | 34 ---------------------------------- 2 files changed, 53 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4489293..6ffdbe2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -16,8 +16,6 @@ pub struct Config { pub intervals_webhook_secret: Option, pub cookie_secure: bool, - - pub dev_sync_days: i64, } impl Config { @@ -50,15 +48,6 @@ impl Config { .parse::() .context("COOKIE_SECURE must be true or false")?; - let dev_sync_days = env::var("DEV_SYNC_DAYS") - .unwrap_or_else(|_| "30".to_string()) - .parse::() - .context("DEV_SYNC_DAYS must be an integer")?; - - if dev_sync_days <= 0 { - anyhow::bail!("DEV_SYNC_DAYS must be greater than zero"); - } - Ok(Self { database_url, bind_address, @@ -73,16 +62,8 @@ impl Config { intervals_webhook_secret, cookie_secure, - - dev_sync_days, }) } - - pub fn require_api_key(&self) -> Result<&str> { - self.intervals_api_key - .as_deref() - .context("INTERVALS_API_KEY is not configured") - } } fn required(name: &str) -> Result { diff --git a/src/db.rs b/src/db.rs index e906cb6..98233b0 100644 --- a/src/db.rs +++ b/src/db.rs @@ -158,40 +158,6 @@ pub async fn delete_old_oauth_states(db: &PgPool) -> Result<()> { Ok(()) } -pub async fn ensure_dev_athlete( - db: &PgPool, - intervals_athlete_id: &str, - display_name: &str, - api_key: &str, -) -> Result { - let row = sqlx::query( - r#" - INSERT INTO athletes ( - intervals_athlete_id, - display_name, - access_token, - scopes - ) - VALUES ($1, $2, $3, 'dev') - ON CONFLICT (intervals_athlete_id) - DO UPDATE SET - display_name = EXCLUDED.display_name, - access_token = EXCLUDED.access_token, - updated_at = now() - RETURNING id - "#, - ) - .bind(intervals_athlete_id) - .bind(display_name) - .bind(api_key) - .fetch_one(db) - .await?; - - use sqlx::Row; - - Ok(row.try_get("id")?) -} - /// Create or update an athlete authenticated with a personal API key. pub async fn upsert_api_key_athlete( db: &PgPool,