Merge branch 'feature/tags' of hc-companies/forecast_api into dev

This commit is contained in:
pt 2020-02-18 22:12:17 +00:00 committed by Gitea
commit 55257733b2
8 changed files with 46 additions and 32 deletions

View File

@ -332,8 +332,9 @@ SELECT
,'replace_version' "version"
,'replace_source'||' volume' iter
,log.id
,COALESCE(log.doc->>'message','') "comment"
,log.doc->>'type' module
,COALESCE(log.doc->>'tag','') "tag"
,log.doc->>'message' "comment"
,log.doc->>'module' module
FROM
basemix b
CROSS JOIN vscale s
@ -418,10 +419,11 @@ SELECT
,b.ship_month
,b.ship_season
,'replace_version' "version"
,'replace_source'||' volume' iter
,'replace_source'||' price' iter
,log.id
,COALESCE(log.doc->>'message','') "comment"
,log.doc->>'type' module
,COALESCE(log.doc->>'tag','') "tag"
,log.doc->>'message' "comment"
,log.doc->>'module' module
FROM
volume b
CROSS JOIN pscale p
@ -466,8 +468,8 @@ FROM
,version
,iter
,logid
,tag
,comment
,module
--------values-------------------------
,sum(value_loc) value_loc
,sum(value_usd) value_usd
@ -509,7 +511,7 @@ FROM
,version
,iter
,logid
,tag
,comment
,module
)
SELECT json_agg(row_to_json(insagg)) x from insagg

View File

@ -1,4 +1,9 @@
BEGIN;
DROP TABLE IF EXISTS rlarp.osm_pool;
DROP TABLE IF EXISTS rlarp.osm_log;
CREATE TABLE IF NOT EXISTS rlarp.osm_log(id INT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, doc jsonb);
CREATE TABLE IF NOT EXISTS rlarp.osm_pool AS (
WITH
@ -101,6 +106,7 @@ SELECT
,version
,iter
,null::int logid
,''::text tag
,''::text "comment"
,''::text module
FROM
@ -133,9 +139,7 @@ FROM
CREATE INDEX osm_qr ON rlarp.osm_pool(quota_rep_descr);
ALTER TABLE rlarp.osm_pool ADD CONSTRAINT logfk FOREIGN KEY (logid) REFERENCES rlarp.osm_log(id);
DROP TABLE IF EXISTS rlarp.osm_log;
CREATE TABLE IF NOT EXISTS rlarp.osm_log(id INT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, doc jsonb);
GRANT ALL ON TABLE rlarp.osm_log TO api;
GRANT ALL ON TABLE rlarp.osm_pool TO api;
COMMIT;

View File

@ -38,8 +38,8 @@ SELECT
,version
,iter
,logid
,tag
,comment
,module
FROM
rlarp.osm_pool
WHERE
@ -77,8 +77,8 @@ GROUP BY
,version
,iter
,logid
,tag
,comment
,module
)
SELECT
json_agg(row_to_json(rows)) x

View File

@ -4,6 +4,7 @@ SELECT
l.doc->>'user' "user",
jsonb_path_query_first(l.doc,'$.scenario.quota_rep_descr')->>0 quota_rep_descr,
to_char((l.doc->>'stamp')::timestamptz,'YYYY-MM-DD HH:MI:SS') "stamp",
l.doc->>'tag' "tag",
l.doc->>'message' "comment",
jsonb_pretty(l.doc) def,
l.id
@ -17,6 +18,7 @@ SELECT
list.user
,list.quota_rep_descr
,list.stamp
,list.tag
,list.comment
,list.def
,list.id
@ -29,6 +31,7 @@ group BY
list.user
,list.quota_rep_descr
,list.stamp
,list.tag
,list.comment
,list.def
,list.id

View File

@ -332,8 +332,9 @@ SELECT
,'replace_version' "version"
,'replace_source'||' volume' iter
,log.id
,COALESCE(log.doc->>'message','') "comment"
,log.doc->>'type' module
,COALESCE(log.doc->>'tag','') "tag"
,log.doc->>'message' "comment"
,log.doc->>'module' module
FROM
basemix b
CROSS JOIN log
@ -453,8 +454,8 @@ FROM
,version
,iter
,logid
,tag
,comment
,module
--------values-------------------------
,sum(value_loc) value_loc
,sum(value_usd) value_usd
@ -496,7 +497,7 @@ FROM
,version
,iter
,logid
,tag
,comment
,module
)
SELECT json_agg(row_to_json(insagg)) x from insagg

View File

@ -167,8 +167,9 @@ target AS (select target_increment incr)
,'replace_version' "version"
,'replace_source'||' price' iter
,log.id
,COALESCE(log.doc->>'message','') "comment"
,log.doc->>'type' module
,COALESCE(log.doc->>'tag','') "tag"
,log.doc->>'message' "comment"
,log.doc->>'module' module
FROM
basemix b
CROSS JOIN scale s
@ -214,8 +215,8 @@ target AS (select target_increment incr)
,version
,iter
,logid
,tag
,comment
,module
--------values-------------------------
,sum(value_loc) value_loc
,sum(value_usd) value_usd
@ -257,7 +258,7 @@ target AS (select target_increment incr)
,version
,iter
,logid
,tag
,comment
,module
)
SELECT json_agg(row_to_json(insagg)) x from insagg

View File

@ -196,8 +196,9 @@ target AS (select incr_qty qincr)
,'replace_version' "version"
,'replace_source'||' volume' iter
,log.id
,COALESCE(log.doc->>'message','') "comment"
,log.doc->>'type' module
,COALESCE(log.doc->>'tag','') "tag"
,log.doc->>'message' "comment"
,log.doc->>'module' module
FROM
basemix b
CROSS JOIN scale s
@ -241,8 +242,8 @@ FROM
,version
,iter
,logid
,tag
,comment
,module
--------values-------------------------
,sum(value_loc) value_loc
,sum(value_usd) value_usd
@ -284,7 +285,7 @@ FROM
,version
,iter
,logid
,tag
,comment
,module
)
SELECT json_agg(row_to_json(insagg)) x from insagg

View File

@ -195,8 +195,9 @@ target AS (select target_vol vincr, target_prc pincr)
,'replace_version' "version"
,'replace_source'||' volume' iter
,log.id
,COALESCE(log.doc->>'message','') "comment"
,log.doc->>'type' module
,COALESCE(log.doc->>'tag','') "tag"
,log.doc->>'message' "comment"
,log.doc->>'module' module
FROM
basemix b
CROSS JOIN vscale s
@ -274,8 +275,9 @@ FROM
,'replace_version' "version"
,'replace_source'||' price' iter
,log.id
,COALESCE(log.doc->>'message','') "comment"
,log.doc->>'type' module
,COALESCE(log.doc->>'tag','') "tag"
,log.doc->>'message' "comment"
,log.doc->>'module' module
FROM
volume b
CROSS JOIN pscale s
@ -321,8 +323,8 @@ FROM
,version
,iter
,logid
,tag
,comment
,module
--------values-------------------------
,sum(value_loc) value_loc
,sum(value_usd) value_usd
@ -364,7 +366,7 @@ FROM
,version
,iter
,logid
,tag
,comment
,module
)
SELECT json_agg(row_to_json(insagg)) x from insagg