From 6fdbc9f9a01aceed0dbf184ef35f5052d9b8846b Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Feb 2026 00:56:21 +0000 Subject: [PATCH] Reduce exchange rate refresh to twice daily MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Be respectful of the free Frankfurter API — ECB rates only update once a day anyway, so a 12-hour cache TTL is more than sufficient. https://claude.ai/code/session_01LPpSZFfyh6vdV5HGFWjoQX --- README.md | 2 +- gaming_deals_bot/currency.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5fc947a..58fc7f5 100644 --- a/README.md +++ b/README.md @@ -49,4 +49,4 @@ All configuration is via environment variables (see `.env.example`): - **Deduplication**: deals are tracked by game ID + timestamp; duplicates are never reposted - **Pruning**: deals older than 30 days are pruned from the database so they can be reposted if they return - **One message per deal**: each deal is posted individually so messages are independently linkable and dismissible -- **Multi-currency pricing**: deal prices are shown in USD, CAD, EUR, and GBP using live exchange rates from the [Frankfurter API](https://api.frankfurter.dev) (ECB data, no API key required). Rates are cached and refreshed hourly. +- **Multi-currency pricing**: deal prices are shown in USD, CAD, EUR, and GBP using live exchange rates from the [Frankfurter API](https://api.frankfurter.dev) (ECB data, no API key required). Rates are cached and refreshed twice daily. diff --git a/gaming_deals_bot/currency.py b/gaming_deals_bot/currency.py index 1a9ad8f..b43acd4 100644 --- a/gaming_deals_bot/currency.py +++ b/gaming_deals_bot/currency.py @@ -1,6 +1,6 @@ """Currency conversion using the Frankfurter API (ECB rates, no API key required). -Rates are cached in memory and refreshed at most once per hour. +Rates are cached in memory and refreshed at most twice per day. """ import logging @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) FRANKFURTER_URL = "https://api.frankfurter.dev/v1/latest" TARGET_CURRENCIES = ("CAD", "EUR", "GBP") -CACHE_TTL_SECONDS = 3600 # 1 hour +CACHE_TTL_SECONDS = 43200 # 12 hours — be nice to the free service # Module-level cache _rates: dict[str, float] = {}