diff --git a/docker-compose.yml b/docker-compose.yml index 9dadac9..d5b1616 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,4 +5,6 @@ services: - "3030:3030" env_file: - .env + volumes: + - ./.token:/app/.token:ro restart: unless-stopped diff --git a/resources/migrations/20260214170000-create-production.down.sql b/resources/migrations/20260214170000-create-production.down.sql new file mode 100644 index 0000000..2b5ad9b --- /dev/null +++ b/resources/migrations/20260214170000-create-production.down.sql @@ -0,0 +1 @@ +DROP TABLE production; diff --git a/resources/migrations/20260214170000-create-production.up.sql b/resources/migrations/20260214170000-create-production.up.sql new file mode 100644 index 0000000..a29bb93 --- /dev/null +++ b/resources/migrations/20260214170000-create-production.up.sql @@ -0,0 +1,6 @@ +CREATE TABLE production ( + time_start TIMESTAMPTZ NOT NULL, + hour INTEGER NOT NULL, + kwh DOUBLE PRECISION, + PRIMARY KEY (time_start, hour) +); diff --git a/resources/migrations/20260214180000-create-consumption.down.sql b/resources/migrations/20260214180000-create-consumption.down.sql new file mode 100644 index 0000000..d9e157a --- /dev/null +++ b/resources/migrations/20260214180000-create-consumption.down.sql @@ -0,0 +1 @@ +DROP TABLE consumption; diff --git a/resources/migrations/20260214180000-create-consumption.up.sql b/resources/migrations/20260214180000-create-consumption.up.sql new file mode 100644 index 0000000..0d1dfad --- /dev/null +++ b/resources/migrations/20260214180000-create-consumption.up.sql @@ -0,0 +1,6 @@ +CREATE TABLE consumption ( + time_start TIMESTAMPTZ NOT NULL, + hour INTEGER NOT NULL, + kwh DOUBLE PRECISION, + PRIMARY KEY (time_start, hour) +); diff --git a/src/clj/pmagnus/elprice/web/controllers/eloverblik.clj b/src/clj/pmagnus/elprice/web/controllers/eloverblik.clj index c424cf0..1940c93 100644 --- a/src/clj/pmagnus/elprice/web/controllers/eloverblik.clj +++ b/src/clj/pmagnus/elprice/web/controllers/eloverblik.clj @@ -31,7 +31,8 @@ (defn- read-refresh-token [] - (str/trim (slurp ".token"))) + (or (System/getenv "ELOVERBLIK_TOKEN") + (str/trim (slurp ".token")))) (defn- get-access-token diff --git a/sync-month.sh b/sync-month.sh index 9516bf8..b2cce4a 100755 --- a/sync-month.sh +++ b/sync-month.sh @@ -9,10 +9,10 @@ if [ $# -ne 1 ]; then fi MONTH="$1" -BASE_URL="${BASE_URL:-http://localhost:3000}" +BASE_URL="${BASE_URL:-http://localhost:3030}" -# Last day of the month (macOS date) -days=$(date -j -v+1m -v-1d -f "%Y-%m-%d" "${MONTH}-01" "+%d") +# Last day of the month +days=$(date -d "${MONTH}-01 +1 month -1 day" "+%d") echo "Syncing $MONTH ($days days)"