diff --git a/index.js b/index.js index af8bcaf..1cdd7a6 100644 --- a/index.js +++ b/index.js @@ -31,7 +31,7 @@ Postgres.FirstRow = function (inSQL, args, inResponse) { }); }; -server.get('/', (req, res) => res.send('node.js express is up and running')) +server.get('/', (req, res) => res.send('node.js express is up and running 🤩')) server.get('/test_sql', function(req, res){ @@ -258,6 +258,10 @@ server.post('/scale_p', bodyParser.json(), function (req, res) { //console.log(args); sql = sql.replace(new RegExp("where_clause",'g'),w); sql = sql.replace(new RegExp("target_increment",'g'),req.body.amount); + sql = sql.replace(new RegExp("replace_version",'g'),req.body.scenario.version); + sql = sql.replace(new RegExp("replace_iteration",'g'),"tool price"); + sql = sql.replace(new RegExp("replace_iterdet",'g'),"addmonth_vupd"); + sql = sql.replace(new RegExp("replace_iterdef",'g'),JSON.stringify(req.body)); //console.log(sql); Postgres.FirstRow(sql,[],res) } diff --git a/route_sql/scale_pd.sql b/route_sql/scale_pd.sql index 2454ff4..0844c96 100644 --- a/route_sql/scale_pd.sql +++ b/route_sql/scale_pd.sql @@ -114,8 +114,6 @@ SELECT -----------------scenario---------------------------- where_clause -----------------additional params------------------- - AND version = 'b20' - AND iter = 'copy' AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments AND adj_orderdate <= adj_shipdate GROUP BY @@ -274,11 +272,11 @@ SELECT ,b.adj_orderdate ,b.adj_requestdate ,b.adj_shipdate - ,b.version --calculated - ,b.iter --calculated + ,'replace_version' "version" --calculated + ,'replace_iteration' "b.iter" --calculated -----------------------ui columns-------------------------------- - ,'scale price' iterdet - ,null::jsonb iterdef + ,'replace_iterdet' iterdet + ,$$replace_iterdef$$::jsonb iterdef ,b.order_season ,b.order_month ,b.ship_season