Add tariff_dkk + total_dkk to elprice
Each hourly row now carries the N1 time-of-use tariff (øre/kWh × 10 to match the DKK/MWh unit of price_dkk) and the combined consumer price (spot + tariff). Existing rows are backfilled in the migration with a CASE expression mirroring tariffs/tariff-for-hour; new writes compute it in the controller. API response exposes both fields. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -67,14 +67,16 @@ VALUES (:time-start, :hour, :kwh)
|
||||
ON CONFLICT (time_start, hour) DO NOTHING;
|
||||
|
||||
-- :name insert-elprice! :! :n
|
||||
-- :doc Insert an hourly el-price row; keep first value on conflict
|
||||
INSERT INTO elprice (time_dk, price_area, price_dkk)
|
||||
VALUES (:time-dk, :price-area, :price-dkk)
|
||||
ON CONFLICT (time_dk, price_area) DO NOTHING;
|
||||
-- :doc Upsert an hourly el-price row; refresh tariff/total on conflict
|
||||
INSERT INTO elprice (time_dk, price_area, price_dkk, tariff_dkk, total_dkk)
|
||||
VALUES (:time-dk, :price-area, :price-dkk, :tariff-dkk, :total-dkk)
|
||||
ON CONFLICT (time_dk, price_area) DO UPDATE SET
|
||||
tariff_dkk = EXCLUDED.tariff_dkk,
|
||||
total_dkk = EXCLUDED.total_dkk;
|
||||
|
||||
-- :name get-elprice-for-date :? :*
|
||||
-- :doc Hourly prices for a DK local date, both areas
|
||||
SELECT time_dk, price_area, price_dkk
|
||||
SELECT time_dk, price_area, price_dkk, tariff_dkk, total_dkk
|
||||
FROM elprice
|
||||
WHERE time_dk::date = :date
|
||||
ORDER BY time_dk, price_area;
|
||||
|
||||
Reference in New Issue
Block a user