Fix local price fetching
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_day_ahead_prices_time_dk_area
|
||||
ON day_ahead_prices (time_dk, price_area);
|
||||
@@ -0,0 +1 @@
|
||||
DROP INDEX IF EXISTS idx_day_ahead_prices_time_dk_area;
|
||||
@@ -1,10 +1,11 @@
|
||||
-- :name insert-price! :! :n
|
||||
-- :doc Insert a day-ahead price record, update DKK if it was null
|
||||
-- :doc Insert/update a day-ahead price record
|
||||
INSERT INTO day_ahead_prices (time_utc, time_dk, price_area, price_dkk, price_eur)
|
||||
VALUES (:time-utc, :time-dk, :price-area, :price-dkk, :price-eur)
|
||||
ON CONFLICT (time_dk, price_area) DO UPDATE SET
|
||||
price_dkk = COALESCE(day_ahead_prices.price_dkk, EXCLUDED.price_dkk),
|
||||
price_eur = COALESCE(day_ahead_prices.price_eur, EXCLUDED.price_eur);
|
||||
ON CONFLICT (time_utc, price_area) DO UPDATE SET
|
||||
time_dk = EXCLUDED.time_dk,
|
||||
price_dkk = EXCLUDED.price_dkk,
|
||||
price_eur = EXCLUDED.price_eur;
|
||||
|
||||
-- :name get-prices-for-date :? :*
|
||||
-- :doc Get all prices for a given date (time_dk local date) and price area
|
||||
|
||||
Reference in New Issue
Block a user