Add Eloverblik data pipeline: fetch metering points, readings, and charges to PostgreSQL
- Add eloverblik controller with API client for metering points, time series, and charges - Add migrations for metering_points, meter_readings, and charges tables - Add HugSQL queries (upsert-metering-point!, insert-meter-reading!, insert-charge!) - Add POST /eloverblik/sync route to trigger sync from browser Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS metering_points;
|
||||
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE metering_points (
|
||||
metering_point_id VARCHAR(18) PRIMARY KEY,
|
||||
type_of_mp VARCHAR(50),
|
||||
balance_supplier VARCHAR(100),
|
||||
street_name VARCHAR(200),
|
||||
building_number VARCHAR(20),
|
||||
postcode VARCHAR(10),
|
||||
city_name VARCHAR(100),
|
||||
has_relation BOOLEAN,
|
||||
settlement_method VARCHAR(50),
|
||||
reading_occurrence VARCHAR(50),
|
||||
consumer_start_date DATE,
|
||||
first_consumer_name VARCHAR(200),
|
||||
fetched_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS meter_readings;
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE meter_readings (
|
||||
metering_point_id VARCHAR(18) NOT NULL REFERENCES metering_points(metering_point_id),
|
||||
time_dk TIMESTAMP NOT NULL,
|
||||
quantity_kwh NUMERIC(10,3),
|
||||
quality VARCHAR(50),
|
||||
PRIMARY KEY (metering_point_id, time_dk)
|
||||
);
|
||||
--;;
|
||||
CREATE INDEX idx_meter_readings_time_dk ON meter_readings(time_dk);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS charges;
|
||||
@@ -0,0 +1,16 @@
|
||||
CREATE TABLE charges (
|
||||
id SERIAL,
|
||||
metering_point_id VARCHAR(18) NOT NULL REFERENCES metering_points(metering_point_id),
|
||||
charge_type VARCHAR(20) NOT NULL,
|
||||
name VARCHAR(200) NOT NULL,
|
||||
description VARCHAR(500),
|
||||
owner VARCHAR(100) NOT NULL,
|
||||
valid_from_date DATE NOT NULL,
|
||||
valid_to_date DATE,
|
||||
period_type VARCHAR(50),
|
||||
price NUMERIC(12,6),
|
||||
quantity INTEGER,
|
||||
position INTEGER NOT NULL DEFAULT 0,
|
||||
fetched_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
UNIQUE (metering_point_id, charge_type, name, owner, valid_from_date, position)
|
||||
);
|
||||
Reference in New Issue
Block a user