diff --git a/01_bank.sql b/01_bank.sql index f1a261d..67a77fc 100644 --- a/01_bank.sql +++ b/01_bank.sql @@ -8,6 +8,8 @@ --show shared_preload_libraries; +alter database iut SET session_preload_libraries = 'anon'; + create schema if not exists ext; create extension if not exists pgcrypto schema ext; create extension if not exists tablefunc; @@ -144,6 +146,9 @@ select 'MXN', date, MXN from eurofxref;*/ insert into exchange_rate select 'NOK', date, NOK from eurofxref; +insert into exchange_rate +select 'SEK', date, NOK from eurofxref; + create or replace function latest_exchange_rate ( p_code text, p_date date diff --git a/02_tools.sql b/02_tools.sql index c8ebc71..556df13 100644 --- a/02_tools.sql +++ b/02_tools.sql @@ -23,3 +23,24 @@ grant select on all tables to metabase_user; /* User grafana */ + +create role grafana_user with + login + nosuperuser + nocreatedb + nocreaterole + noinherit + noreplication + connection limit -1 + password 'supermotdepasse'; + + grant usage + on schema public + to grafana_user; + +grant select on all tables + in schema public + to grafana_user; + +create extension anon; +select anon.init(); diff --git a/Currencies-1764353031586.json b/Currencies-1764357365652.json similarity index 76% rename from Currencies-1764353031586.json rename to Currencies-1764357365652.json index f779a16..5610718 100644 --- a/Currencies-1764353031586.json +++ b/Currencies-1764357365652.json @@ -37,6 +37,7 @@ "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", + "axisSoftMin": 0, "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", @@ -83,7 +84,7 @@ }, "gridPos": { "h": 8, - "w": 12, + "w": 24, "x": 0, "y": 0 }, @@ -111,7 +112,7 @@ "editorMode": "code", "format": "table", "rawQuery": true, - "rawSql": "select date, rate, currency_code from exchange_rate ", + "rawSql": "select date, rate, currency_code from exchange_rate where currency_code in (${devises:sqlstring}) and $__timeFilter(date) ", "refId": "A", "sql": { "columns": [ @@ -133,6 +134,17 @@ } ], "title": "Devises", + "transformations": [ + { + "id": "partitionByValues", + "options": { + "fields": [ + "currency_code" + ], + "keepFields": false + } + } + ], "type": "timeseries" } ], @@ -140,15 +152,43 @@ "schemaVersion": 41, "tags": [], "templating": { - "list": [] + "list": [ + { + "allowCustomValue": false, + "current": { + "text": [ + "SEK", + "NOK" + ], + "value": [ + "SEK", + "NOK" + ] + }, + "definition": "select code from currency", + "label": "Devises", + "multi": true, + "name": "devises", + "options": [], + "query": "select code from currency", + "refresh": 1, + "regex": "", + "type": "query" + } + ] }, "time": { - "from": "1999-01-04T00:00:00.000Z", - "to": "2025-11-26T00:00:00.000Z" + "from": "2023-08-10T14:12:24.380Z", + "to": "2025-01-08T14:48:00.110Z" + }, + "timepicker": { + "refresh_intervals": [ + "2h", + "1d" + ] }, - "timepicker": {}, "timezone": "browser", "title": "Currencies", "uid": "967255c7-9164-487e-807f-154605a34e32", - "version": 1 + "version": 5 } \ No newline at end of file