turn on sql execution for scale route, but not working

This commit is contained in:
Paul Trowbridge 2022-04-22 00:22:35 -04:00
parent 2531914387
commit d47b00b5cd
3 changed files with 12 additions and 8 deletions

View File

@ -111,6 +111,7 @@ server.get('/scale', bodyParser.json(), function(req, res) {
var app_pincr = req.body.app_pincr;
var app_req = JSON.stringify(req.body);
var app_vincr = req.body.app_vincr;
var app_forecast_name = req.body.app_forecast_name;
var callback = function(arg) {
sql = arg;
@ -120,19 +121,21 @@ server.get('/scale', bodyParser.json(), function(req, res) {
// res.send("no body was sent");
// return;
//}
console.log(new Date().toISOString() + "-------------------------baseline build-----------------------------")
console.log(new Date().toISOString() + "-------------------------scale type adjustment----------------------")
console.log(JSON.stringify(req.body));
//parse the where clause into the main sql statement
//sql = sql.replace(new RegExp("where_clause", 'g'), w)
//sql = sql.replace(new RegExp("app_pincr", 'g'), app_pincr);
sql = sql.replace(new RegExp("app_req", 'g'), app_req);
sql = sql.replace(new RegExp("app_forecast_name", 'g'), app_forecast_name);
//sql = sql.replace(new RegExp("app_vincr", 'g'), app_vincr);
sql = sql.replace(new RegExp("app_where", 'g'), w);
//execute the sql and send the result
args.push(req.body.app_baseline_from_date);
console.log(sql);
res.send(sql);
//Postgres.FirstRow(sql, [], res)
//send only the sql as the result of the route for debug
//res.send(sql);
Postgres.FirstRow(sql, [], res)
};
fs.readFile(path, 'utf8', function(err, data) {

View File

@ -2,7 +2,7 @@
"app_scenario": {
"\"Description\"": "TARGET STOW OH",
"app_iter": [
"baseline"
"baseline","scale price"
]
},
"stamp": "2020-02-19 17:03:38",
@ -11,7 +11,8 @@
"message": "test json",
"tag": "standard price",
"version": "dev",
"app_forecast_name": "dev",
"type": "scale_vp",
"app_vincr": 0,
"app_pincr": 2000
"app_pincr": 500
}

View File

@ -38,10 +38,10 @@ SELECT
,o."Category"
,o."Party"
,o."Reason"
,sum(o.app_units) AS app_units
,'app_forecast_name' AS app_version
,'scale' AS app_iter
,0::bigint AS app_logid
,sum(o.app_units) AS app_units
FROM
tpsv.dcard o
WHERE
@ -75,10 +75,10 @@ SELECT
,o."Category"
,o."Party"
,o."Reason"
,round(o.app_units * vscale.factor,5) AS app_units
,'app_forecast_name' AS app_version
,'scale volume' AS app_iter
,(SELECT id FROM ilog) AS app_logid
,round(o.app_units * vscale.factor,5) AS app_units
FROM
basemix o
CROSS JOIN vscale
@ -130,10 +130,10 @@ SELECT
,o."Category"
,o."Party"
,o."Reason"
,0::numeric AS app_units
,'app_forecast_name' AS app_version
,'scale price' AS app_iter
,(SELECT id FROM ilog) AS app_logid
,0::numeric AS app_units
FROM
volume o
CROSS JOIN pscale