Use eur if not present
This commit is contained in:
+16
-2
@@ -1,8 +1,10 @@
|
||||
-- :name insert-price! :! :n
|
||||
-- :doc Insert a day-ahead price record, skip if already exists
|
||||
-- :doc Insert a day-ahead price record, update DKK if it was null
|
||||
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 NOTHING;
|
||||
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);
|
||||
|
||||
-- :name get-prices-for-date :? :*
|
||||
-- :doc Get all prices for a given date (time_dk local date) and price area
|
||||
@@ -54,6 +56,18 @@ SELECT count(*) AS cnt
|
||||
FROM consumption
|
||||
WHERE time_start = :time-start;
|
||||
|
||||
-- :name count-production-for-date :? :1
|
||||
-- :doc Count production records for a given UTC time_start
|
||||
SELECT count(*) AS cnt
|
||||
FROM production
|
||||
WHERE time_start = :time-start;
|
||||
|
||||
-- :name count-meter-readings-for-date :? :1
|
||||
-- :doc Count meter readings for a given UTC time_start (converted to DK date range)
|
||||
SELECT count(*) AS cnt
|
||||
FROM meter_readings
|
||||
WHERE time_dk >= :from-dk AND time_dk < :to-dk;
|
||||
|
||||
-- :name insert-production! :! :n
|
||||
-- :doc Insert a production record, skip if already exists
|
||||
INSERT INTO production (time_start, hour, kwh)
|
||||
|
||||
Reference in New Issue
Block a user