From b6464e51b91377d735226185a5e34686195dd110 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 19 Mar 2019 10:56:11 -0400 Subject: [PATCH 1/3] creat elist of active parts with descriptions --- route_sql/part_list.sql | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 route_sql/part_list.sql diff --git a/route_sql/part_list.sql b/route_sql/part_list.sql new file mode 100644 index 0000000..d0ce852 --- /dev/null +++ b/route_sql/part_list.sql @@ -0,0 +1,23 @@ +WITH +act As ( + SELECT DISTINCT + v6part part + FROM + lgdat.stka + WHERE + v6stat = 'A' +) +,stkm AS ( + SELECT + act.part || ' - ' ||rtrim(COALESCE(m.avdes1,p.awdes1)) part + --,COALESCE(m.avgled, p.awgled) glec + FROM + act + LEFT OUTER JOIN lgdat.stkmm m ON + m.avpart = act.part + LEFT OUTER JOIN lgdat.stkmp p ON + p.awpart = act.part + WHERE + substr(COALESCE(m.avgled, p.awgled),1,1) <= '2' +) +select part from stkm \ No newline at end of file From 5245bfac74c29de385f300685b063624df8d8253 Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Wed, 20 Mar 2019 00:37:36 -0400 Subject: [PATCH 2/3] add a part list and log sql statements --- .gitignore | 1 + index.js | 9 ++++----- route_sql/part_list.sql | 44 ++++++++++++++++++++--------------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 7c4938e..0d4430a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ npm-debug.log logs.html stat.html *.pem +node.log \ No newline at end of file diff --git a/index.js b/index.js index da6b600..cd609eb 100644 --- a/index.js +++ b/index.js @@ -162,7 +162,6 @@ server.post('/addmonth_v', bodyParser.json(), function (req, res) { sql = sql.replace(new RegExp("replace_version",'g'),req.body.scenario.version); sql = sql.replace(new RegExp("replace_source",'g'),req.body.source); sql = sql.replace(new RegExp("replace_iterdef",'g'),JSON.stringify(req.body)); - //console.log(sql); console.log(sql) Postgres.FirstRow(sql,[],res) } @@ -196,7 +195,7 @@ server.post('/addmonth_vp', bodyParser.json(), function (req, res) { sql = sql.replace(new RegExp("replace_version",'g'),req.body.scenario.version); sql = sql.replace(new RegExp("replace_source",'g'),req.body.source); sql = sql.replace(new RegExp("replace_iterdef",'g'),JSON.stringify(req.body)); - //console.log(sql); + console.log(sql); Postgres.FirstRow(sql,[],res) } @@ -236,7 +235,7 @@ server.post('/scale_v', bodyParser.json(), function (req, res) { sql = sql.replace(new RegExp("replace_version",'g'),req.body.scenario.version); sql = sql.replace(new RegExp("replace_source",'g'),req.body.source); sql = sql.replace(new RegExp("replace_iterdef",'g'),JSON.stringify(req.body)); - //console.log(sql); + console.log(sql); Postgres.FirstRow(sql,[],res) } @@ -276,7 +275,7 @@ server.post('/scale_p', bodyParser.json(), function (req, res) { sql = sql.replace(new RegExp("replace_version",'g'),req.body.scenario.version); sql = sql.replace(new RegExp("replace_source",'g'),req.body.source); sql = sql.replace(new RegExp("replace_iterdef",'g'),JSON.stringify(req.body)); - //console.log(sql); + console.log(sql); Postgres.FirstRow(sql,[],res) } @@ -317,7 +316,7 @@ server.post('/scale_vp', bodyParser.json(), function (req, res) { sql = sql.replace(new RegExp("replace_version",'g'),req.body.scenario.version); sql = sql.replace(new RegExp("replace_source",'g'),req.body.source); sql = sql.replace(new RegExp("replace_iterdef",'g'),JSON.stringify(req.body)); - //console.log(sql); + console.log(sql); Postgres.FirstRow(sql,[],res) } diff --git a/route_sql/part_list.sql b/route_sql/part_list.sql index d0ce852..33e388c 100644 --- a/route_sql/part_list.sql +++ b/route_sql/part_list.sql @@ -1,23 +1,23 @@ -WITH -act As ( - SELECT DISTINCT - v6part part - FROM - lgdat.stka - WHERE - v6stat = 'A' -) -,stkm AS ( - SELECT - act.part || ' - ' ||rtrim(COALESCE(m.avdes1,p.awdes1)) part - --,COALESCE(m.avgled, p.awgled) glec - FROM - act - LEFT OUTER JOIN lgdat.stkmm m ON - m.avpart = act.part - LEFT OUTER JOIN lgdat.stkmp p ON - p.awpart = act.part - WHERE - substr(COALESCE(m.avgled, p.awgled),1,1) <= '2' -) +WITH +act As ( + SELECT DISTINCT + v6part part + FROM + lgdat.stka + WHERE + v6stat = 'A' +) +,stkm AS ( + SELECT + act.part || ' - ' ||rtrim(COALESCE(m.avdes1,p.awdes1)) part + --,COALESCE(m.avgled, p.awgled) glec + FROM + act + LEFT OUTER JOIN lgdat.stkmm m ON + m.avpart = act.part + LEFT OUTER JOIN lgdat.stkmp p ON + p.awpart = act.part + WHERE + substr(COALESCE(m.avgled, p.awgled),1,1) <= '2' +) select part from stkm \ No newline at end of file From b05d68f8ec7d000470fcc0800344cf0bca65b575 Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Wed, 20 Mar 2019 01:31:51 -0400 Subject: [PATCH 3/3] dont sum up diext and discounts --- route_sql/addmonth_vd.sql | 4 ++-- route_sql/addmonth_vupd.sql | 4 ++-- route_sql/scale_pd.sql | 4 ++-- route_sql/scale_vd.sql | 4 ++-- route_sql/scale_vupd.sql | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/route_sql/addmonth_vd.sql b/route_sql/addmonth_vd.sql index 1277fbb..7588bcb 100644 --- a/route_sql/addmonth_vd.sql +++ b/route_sql/addmonth_vd.sql @@ -151,8 +151,8 @@ SELECT ,terms ,''::text custpo --0 ,'I' dhincr --0 - ,sum(diext) diext - ,sum(ditdis) ditdis + ,null::numeric diext + ,null::numeric ditdis ,null::date dcodat --calculated date mix ,null::date ddqdat --calculated date mix ,null::date dcmdat --calculated date mix diff --git a/route_sql/addmonth_vupd.sql b/route_sql/addmonth_vupd.sql index 75918c2..a876885 100644 --- a/route_sql/addmonth_vupd.sql +++ b/route_sql/addmonth_vupd.sql @@ -145,8 +145,8 @@ SELECT ,terms ,''::text custpo --0 ,'I' dhincr --0 - ,sum(diext) diext - ,sum(ditdis) ditdis + ,null::numeric diext + ,null::numeric ditdis ,null::date dcodat --calculated date mix ,null::date ddqdat --calculated date mix ,null::date dcmdat --calculated date mix diff --git a/route_sql/scale_pd.sql b/route_sql/scale_pd.sql index 81145bc..0c6110e 100644 --- a/route_sql/scale_pd.sql +++ b/route_sql/scale_pd.sql @@ -14,8 +14,8 @@ SELECT ,terms ,''::text custpo --0 ,'I' dhincr --0 - ,sum(diext) diext - ,sum(ditdis) ditdis + ,null::numeric diext + ,null::numeric ditdis ,null::date dcodat --calculated date mix ,null::date ddqdat --calculated date mix ,null::date dcmdat --calculated date mix diff --git a/route_sql/scale_vd.sql b/route_sql/scale_vd.sql index 8148cf3..fbaa219 100644 --- a/route_sql/scale_vd.sql +++ b/route_sql/scale_vd.sql @@ -14,8 +14,8 @@ SELECT ,terms ,''::text custpo --0 ,'I' dhincr --0 - ,sum(diext) diext - ,sum(ditdis) ditdis + ,null::numeric diext + ,null::numeric ditdis ,null::date dcodat --calculated date mix ,null::date ddqdat --calculated date mix ,null::date dcmdat --calculated date mix diff --git a/route_sql/scale_vupd.sql b/route_sql/scale_vupd.sql index faddaa9..16e73cc 100644 --- a/route_sql/scale_vupd.sql +++ b/route_sql/scale_vupd.sql @@ -14,8 +14,8 @@ target AS (select target_vol vincr, target_prc pincr) ,terms ,''::text custpo --0 ,'I' dhincr --0 - ,sum(diext) diext - ,sum(ditdis) ditdis + ,null::numeric diext + ,null::numeric ditdis ,null::date dcodat --calculated date mix ,null::date ddqdat --calculated date mix ,null::date dcmdat --calculated date mix