From d3a4a45d536457796b3edac4c655f4d475d82261 Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Tue, 18 Feb 2020 14:47:46 -0500 Subject: [PATCH 1/3] change comment to be the tag --- route_sql/addmonth_vupd.sql | 8 ++++---- route_sql/build/build_fcpool.sql | 2 +- route_sql/get_pool.sql | 4 ++-- route_sql/list_changes.sql | 6 +++--- route_sql/new_basket.sql | 6 +++--- route_sql/scale_pd.sql | 6 +++--- route_sql/scale_vd.sql | 6 +++--- route_sql/scale_vupd.sql | 8 ++++---- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/route_sql/addmonth_vupd.sql b/route_sql/addmonth_vupd.sql index d593b01..9f8bac4 100644 --- a/route_sql/addmonth_vupd.sql +++ b/route_sql/addmonth_vupd.sql @@ -332,7 +332,7 @@ SELECT ,'replace_version' "version" ,'replace_source'||' volume' iter ,log.id - ,COALESCE(log.doc->>'message','') "comment" + ,COALESCE(log.doc->>'tag','') "tag" ,log.doc->>'type' module FROM basemix b @@ -420,7 +420,7 @@ SELECT ,'replace_version' "version" ,'replace_source'||' volume' iter ,log.id - ,COALESCE(log.doc->>'message','') "comment" + ,COALESCE(log.doc->>'tag','') "tag" ,log.doc->>'type' module FROM volume b @@ -466,7 +466,7 @@ FROM ,version ,iter ,logid - ,comment + ,tag ,module --------values------------------------- ,sum(value_loc) value_loc @@ -509,7 +509,7 @@ FROM ,version ,iter ,logid - ,comment + ,tag ,module ) SELECT json_agg(row_to_json(insagg)) x from insagg \ No newline at end of file diff --git a/route_sql/build/build_fcpool.sql b/route_sql/build/build_fcpool.sql index 0ddcdcd..2071883 100644 --- a/route_sql/build/build_fcpool.sql +++ b/route_sql/build/build_fcpool.sql @@ -101,7 +101,7 @@ SELECT ,version ,iter ,null::int logid - ,''::text "comment" + ,''::text tag ,''::text module FROM rlarp.osmf_dev o diff --git a/route_sql/get_pool.sql b/route_sql/get_pool.sql index 0e68159..6cc4c81 100644 --- a/route_sql/get_pool.sql +++ b/route_sql/get_pool.sql @@ -38,7 +38,7 @@ SELECT ,version ,iter ,logid - ,comment + ,tag ,module FROM rlarp.osm_pool @@ -77,7 +77,7 @@ GROUP BY ,version ,iter ,logid - ,comment + ,tag ,module ) SELECT diff --git a/route_sql/list_changes.sql b/route_sql/list_changes.sql index 64dfabe..8551431 100644 --- a/route_sql/list_changes.sql +++ b/route_sql/list_changes.sql @@ -4,7 +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->>'message' "comment", + l.doc->>'tag' "tag", jsonb_pretty(l.doc) def, l.id FROM @@ -17,7 +17,7 @@ SELECT list.user ,list.quota_rep_descr ,list.stamp - ,list.comment + ,list.tag ,list.def ,list.id ,to_char(round(sum(value_usd),2),'$999,999,999D00') sales @@ -29,7 +29,7 @@ group BY list.user ,list.quota_rep_descr ,list.stamp - ,list.comment + ,list.tag ,list.def ,list.id ) diff --git a/route_sql/new_basket.sql b/route_sql/new_basket.sql index 1ed7f36..71f55da 100644 --- a/route_sql/new_basket.sql +++ b/route_sql/new_basket.sql @@ -332,7 +332,7 @@ SELECT ,'replace_version' "version" ,'replace_source'||' volume' iter ,log.id - ,COALESCE(log.doc->>'message','') "comment" + ,COALESCE(log.doc->>'tag','') "tag" ,log.doc->>'type' module FROM basemix b @@ -453,7 +453,7 @@ FROM ,version ,iter ,logid - ,comment + ,tag ,module --------values------------------------- ,sum(value_loc) value_loc @@ -496,7 +496,7 @@ FROM ,version ,iter ,logid - ,comment + ,tag ,module ) SELECT json_agg(row_to_json(insagg)) x from insagg \ No newline at end of file diff --git a/route_sql/scale_pd.sql b/route_sql/scale_pd.sql index 1638e70..36f2606 100644 --- a/route_sql/scale_pd.sql +++ b/route_sql/scale_pd.sql @@ -167,7 +167,7 @@ target AS (select target_increment incr) ,'replace_version' "version" ,'replace_source'||' price' iter ,log.id - ,COALESCE(log.doc->>'message','') "comment" + ,COALESCE(log.doc->>'tag','') "tag" ,log.doc->>'type' module FROM basemix b @@ -214,7 +214,7 @@ target AS (select target_increment incr) ,version ,iter ,logid - ,comment + ,tag ,module --------values------------------------- ,sum(value_loc) value_loc @@ -257,7 +257,7 @@ target AS (select target_increment incr) ,version ,iter ,logid - ,comment + ,tag ,module ) SELECT json_agg(row_to_json(insagg)) x from insagg diff --git a/route_sql/scale_vd.sql b/route_sql/scale_vd.sql index 9d09f1a..c53b9cc 100644 --- a/route_sql/scale_vd.sql +++ b/route_sql/scale_vd.sql @@ -196,7 +196,7 @@ target AS (select incr_qty qincr) ,'replace_version' "version" ,'replace_source'||' volume' iter ,log.id - ,COALESCE(log.doc->>'message','') "comment" + ,COALESCE(log.doc->>'tag','') "tag" ,log.doc->>'type' module FROM basemix b @@ -241,7 +241,7 @@ FROM ,version ,iter ,logid - ,comment + ,tag ,module --------values------------------------- ,sum(value_loc) value_loc @@ -284,7 +284,7 @@ FROM ,version ,iter ,logid - ,comment + ,tag ,module ) SELECT json_agg(row_to_json(insagg)) x from insagg \ No newline at end of file diff --git a/route_sql/scale_vupd.sql b/route_sql/scale_vupd.sql index cdfdd7a..c72741a 100644 --- a/route_sql/scale_vupd.sql +++ b/route_sql/scale_vupd.sql @@ -195,7 +195,7 @@ target AS (select target_vol vincr, target_prc pincr) ,'replace_version' "version" ,'replace_source'||' volume' iter ,log.id - ,COALESCE(log.doc->>'message','') "comment" + ,COALESCE(log.doc->>'tag','') "tag" ,log.doc->>'type' module FROM basemix b @@ -274,7 +274,7 @@ FROM ,'replace_version' "version" ,'replace_source'||' price' iter ,log.id - ,COALESCE(log.doc->>'message','') "comment" + ,COALESCE(log.doc->>'tag','') "tag" ,log.doc->>'type' module FROM volume b @@ -321,7 +321,7 @@ FROM ,version ,iter ,logid - ,comment + ,tag ,module --------values------------------------- ,sum(value_loc) value_loc @@ -364,7 +364,7 @@ FROM ,version ,iter ,logid - ,comment + ,tag ,module ) SELECT json_agg(row_to_json(insagg)) x from insagg From 69346646bda420fb2a91c07d0b9c680aa633db8c Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Tue, 18 Feb 2020 15:35:56 -0500 Subject: [PATCH 2/3] change module to be the comment --- route_sql/addmonth_vupd.sql | 8 ++++---- route_sql/build/build_fcpool.sql | 15 +++++++++------ route_sql/get_pool.sql | 4 ++-- route_sql/new_basket.sql | 6 +++--- route_sql/scale_pd.sql | 6 +++--- route_sql/scale_vd.sql | 6 +++--- route_sql/scale_vupd.sql | 8 ++++---- 7 files changed, 28 insertions(+), 25 deletions(-) diff --git a/route_sql/addmonth_vupd.sql b/route_sql/addmonth_vupd.sql index 9f8bac4..1f48044 100644 --- a/route_sql/addmonth_vupd.sql +++ b/route_sql/addmonth_vupd.sql @@ -333,7 +333,7 @@ SELECT ,'replace_source'||' volume' iter ,log.id ,COALESCE(log.doc->>'tag','') "tag" - ,log.doc->>'type' module + ,log.doc->>'message' "comment" FROM basemix b CROSS JOIN vscale s @@ -421,7 +421,7 @@ SELECT ,'replace_source'||' volume' iter ,log.id ,COALESCE(log.doc->>'tag','') "tag" - ,log.doc->>'type' module + ,log.doc->>'message' "comment" FROM volume b CROSS JOIN pscale p @@ -467,7 +467,7 @@ FROM ,iter ,logid ,tag - ,module + ,comment --------values------------------------- ,sum(value_loc) value_loc ,sum(value_usd) value_usd @@ -510,6 +510,6 @@ FROM ,iter ,logid ,tag - ,module + ,comment ) SELECT json_agg(row_to_json(insagg)) x from insagg \ No newline at end of file diff --git a/route_sql/build/build_fcpool.sql b/route_sql/build/build_fcpool.sql index 2071883..243edf3 100644 --- a/route_sql/build/build_fcpool.sql +++ b/route_sql/build/build_fcpool.sql @@ -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 @@ -102,7 +107,7 @@ SELECT ,iter ,null::int logid ,''::text tag - ,''::text module + ,''::text "comment" FROM rlarp.osmf_dev o LEFT OUTER JOIN lgdat.cust bc ON @@ -133,9 +138,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; \ No newline at end of file +GRANT ALL ON TABLE rlarp.osm_pool TO api; + +COMMIT; \ No newline at end of file diff --git a/route_sql/get_pool.sql b/route_sql/get_pool.sql index 6cc4c81..24e9004 100644 --- a/route_sql/get_pool.sql +++ b/route_sql/get_pool.sql @@ -39,7 +39,7 @@ SELECT ,iter ,logid ,tag - ,module + ,comment FROM rlarp.osm_pool WHERE @@ -78,7 +78,7 @@ GROUP BY ,iter ,logid ,tag - ,module + ,comment ) SELECT json_agg(row_to_json(rows)) x diff --git a/route_sql/new_basket.sql b/route_sql/new_basket.sql index 71f55da..cd52d18 100644 --- a/route_sql/new_basket.sql +++ b/route_sql/new_basket.sql @@ -333,7 +333,7 @@ SELECT ,'replace_source'||' volume' iter ,log.id ,COALESCE(log.doc->>'tag','') "tag" - ,log.doc->>'type' module + ,log.doc->>'message' "comment" FROM basemix b CROSS JOIN log @@ -454,7 +454,7 @@ FROM ,iter ,logid ,tag - ,module + ,comment --------values------------------------- ,sum(value_loc) value_loc ,sum(value_usd) value_usd @@ -497,6 +497,6 @@ FROM ,iter ,logid ,tag - ,module + ,comment ) SELECT json_agg(row_to_json(insagg)) x from insagg \ No newline at end of file diff --git a/route_sql/scale_pd.sql b/route_sql/scale_pd.sql index 36f2606..a835d58 100644 --- a/route_sql/scale_pd.sql +++ b/route_sql/scale_pd.sql @@ -168,7 +168,7 @@ target AS (select target_increment incr) ,'replace_source'||' price' iter ,log.id ,COALESCE(log.doc->>'tag','') "tag" - ,log.doc->>'type' module + ,log.doc->>'message' "comment" FROM basemix b CROSS JOIN scale s @@ -215,7 +215,7 @@ target AS (select target_increment incr) ,iter ,logid ,tag - ,module + ,comment --------values------------------------- ,sum(value_loc) value_loc ,sum(value_usd) value_usd @@ -258,6 +258,6 @@ target AS (select target_increment incr) ,iter ,logid ,tag - ,module + ,comment ) SELECT json_agg(row_to_json(insagg)) x from insagg diff --git a/route_sql/scale_vd.sql b/route_sql/scale_vd.sql index c53b9cc..866006a 100644 --- a/route_sql/scale_vd.sql +++ b/route_sql/scale_vd.sql @@ -197,7 +197,7 @@ target AS (select incr_qty qincr) ,'replace_source'||' volume' iter ,log.id ,COALESCE(log.doc->>'tag','') "tag" - ,log.doc->>'type' module + ,log.doc->>'message' "comment" FROM basemix b CROSS JOIN scale s @@ -242,7 +242,7 @@ FROM ,iter ,logid ,tag - ,module + ,comment --------values------------------------- ,sum(value_loc) value_loc ,sum(value_usd) value_usd @@ -285,6 +285,6 @@ FROM ,iter ,logid ,tag - ,module + ,comment ) SELECT json_agg(row_to_json(insagg)) x from insagg \ No newline at end of file diff --git a/route_sql/scale_vupd.sql b/route_sql/scale_vupd.sql index c72741a..5e95d83 100644 --- a/route_sql/scale_vupd.sql +++ b/route_sql/scale_vupd.sql @@ -196,7 +196,7 @@ target AS (select target_vol vincr, target_prc pincr) ,'replace_source'||' volume' iter ,log.id ,COALESCE(log.doc->>'tag','') "tag" - ,log.doc->>'type' module + ,log.doc->>'message' "comment" FROM basemix b CROSS JOIN vscale s @@ -275,7 +275,7 @@ FROM ,'replace_source'||' price' iter ,log.id ,COALESCE(log.doc->>'tag','') "tag" - ,log.doc->>'type' module + ,log.doc->>'message' "comment" FROM volume b CROSS JOIN pscale s @@ -322,7 +322,7 @@ FROM ,iter ,logid ,tag - ,module + ,comment --------values------------------------- ,sum(value_loc) value_loc ,sum(value_usd) value_usd @@ -365,6 +365,6 @@ FROM ,iter ,logid ,tag - ,module + ,comment ) SELECT json_agg(row_to_json(insagg)) x from insagg From cbc2caa41d0593e8c2d891951391f760d4209e0a Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Tue, 18 Feb 2020 17:10:49 -0500 Subject: [PATCH 3/3] add module back in --- route_sql/addmonth_vupd.sql | 4 +++- route_sql/build/build_fcpool.sql | 1 + route_sql/list_changes.sql | 3 +++ route_sql/new_basket.sql | 1 + route_sql/scale_pd.sql | 1 + route_sql/scale_vd.sql | 1 + route_sql/scale_vupd.sql | 2 ++ 7 files changed, 12 insertions(+), 1 deletion(-) diff --git a/route_sql/addmonth_vupd.sql b/route_sql/addmonth_vupd.sql index 1f48044..1994df1 100644 --- a/route_sql/addmonth_vupd.sql +++ b/route_sql/addmonth_vupd.sql @@ -334,6 +334,7 @@ SELECT ,log.id ,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->>'tag','') "tag" ,log.doc->>'message' "comment" + ,log.doc->>'module' module FROM volume b CROSS JOIN pscale p diff --git a/route_sql/build/build_fcpool.sql b/route_sql/build/build_fcpool.sql index 243edf3..3c30798 100644 --- a/route_sql/build/build_fcpool.sql +++ b/route_sql/build/build_fcpool.sql @@ -108,6 +108,7 @@ SELECT ,null::int logid ,''::text tag ,''::text "comment" + ,''::text module FROM rlarp.osmf_dev o LEFT OUTER JOIN lgdat.cust bc ON diff --git a/route_sql/list_changes.sql b/route_sql/list_changes.sql index 8551431..d710609 100644 --- a/route_sql/list_changes.sql +++ b/route_sql/list_changes.sql @@ -5,6 +5,7 @@ SELECT 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 FROM @@ -18,6 +19,7 @@ SELECT ,list.quota_rep_descr ,list.stamp ,list.tag + ,list.comment ,list.def ,list.id ,to_char(round(sum(value_usd),2),'$999,999,999D00') sales @@ -30,6 +32,7 @@ group BY ,list.quota_rep_descr ,list.stamp ,list.tag + ,list.comment ,list.def ,list.id ) diff --git a/route_sql/new_basket.sql b/route_sql/new_basket.sql index cd52d18..c22df8f 100644 --- a/route_sql/new_basket.sql +++ b/route_sql/new_basket.sql @@ -334,6 +334,7 @@ SELECT ,log.id ,COALESCE(log.doc->>'tag','') "tag" ,log.doc->>'message' "comment" + ,log.doc->>'module' module FROM basemix b CROSS JOIN log diff --git a/route_sql/scale_pd.sql b/route_sql/scale_pd.sql index a835d58..1804a70 100644 --- a/route_sql/scale_pd.sql +++ b/route_sql/scale_pd.sql @@ -169,6 +169,7 @@ target AS (select target_increment incr) ,log.id ,COALESCE(log.doc->>'tag','') "tag" ,log.doc->>'message' "comment" + ,log.doc->>'module' module FROM basemix b CROSS JOIN scale s diff --git a/route_sql/scale_vd.sql b/route_sql/scale_vd.sql index 866006a..347496e 100644 --- a/route_sql/scale_vd.sql +++ b/route_sql/scale_vd.sql @@ -198,6 +198,7 @@ target AS (select incr_qty qincr) ,log.id ,COALESCE(log.doc->>'tag','') "tag" ,log.doc->>'message' "comment" + ,log.doc->>'module' module FROM basemix b CROSS JOIN scale s diff --git a/route_sql/scale_vupd.sql b/route_sql/scale_vupd.sql index 5e95d83..ab9af26 100644 --- a/route_sql/scale_vupd.sql +++ b/route_sql/scale_vupd.sql @@ -197,6 +197,7 @@ target AS (select target_vol vincr, target_prc pincr) ,log.id ,COALESCE(log.doc->>'tag','') "tag" ,log.doc->>'message' "comment" + ,log.doc->>'module' module FROM basemix b CROSS JOIN vscale s @@ -276,6 +277,7 @@ FROM ,log.id ,COALESCE(log.doc->>'tag','') "tag" ,log.doc->>'message' "comment" + ,log.doc->>'module' module FROM volume b CROSS JOIN pscale s