Add GET /api/currencies/:date endpoint for historical EUR/DKK rates
Returns rates for a given date: today uses latest DB row, past dates check DB first then fetch from Frankfurter and persist for caching. Future dates and invalid formats return 400. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -60,4 +60,8 @@ SET eur = EXCLUDED.eur, dkk = EXCLUDED.dkk, eur_dkk = EXCLUDED.eur_dkk, updated_
|
||||
|
||||
-- :name get-latest-currency-rates :? :1
|
||||
-- :doc Get the most recent currency rates
|
||||
SELECT eur, dkk, eur_dkk, updated_at FROM currencies ORDER BY rate_date DESC LIMIT 1
|
||||
SELECT rate_date, eur, dkk, eur_dkk, updated_at FROM currencies ORDER BY rate_date DESC LIMIT 1
|
||||
|
||||
-- :name get-currency-rates-by-date :? :1
|
||||
-- :doc Get currency rates for a specific date
|
||||
SELECT rate_date, eur, dkk, eur_dkk, updated_at FROM currencies WHERE rate_date = :rate-date
|
||||
|
||||
Reference in New Issue
Block a user