Compare commits

..

No commits in common. "db3b267657495e79a05de5bd4cc3b042ae239ce0" and "9e381f7d789081f973748d1b843a6bbc86fc78a9" have entirely different histories.

4 changed files with 8 additions and 19 deletions

View File

@ -40,13 +40,10 @@ const SQLTemplate = (inSql, inJSON) => {
} }
return inSql; return inSql;
}; };
const build_where = (req, c, w) => { const build_where = (req, c, w, d, args) => {
//loop through each top level item expected to be a simple key/value list reflecting the column and the target value //loop through each top level item expected to be a simple key/value list reflecting the column and the target value
// "part":"XFRM500", "customer":"Sanford and Son" --> SQL --> part = 'XFRM500' // "part":"XFRM500", "customer":"Sanford and Son" --> SQL --> part = 'XFRM500'
// AND customer = 'Sanford and Son' // AND customer = 'Sanford and Son'
var d = 1;
var args = [];
for (var i in req.body.app_scenario) { for (var i in req.body.app_scenario) {
//console.log(i); //console.log(i);
///console.log(req.body[i]); ///console.log(req.body[i]);
@ -74,7 +71,7 @@ const build_where = (req, c, w) => {
args.push(req.body.app_scenario[i]); args.push(req.body.app_scenario[i]);
c = c + 1; c = c + 1;
}; };
return { c, w }; return { c, w, d };
} }
//------------route to test if the process is running------------------------------- //------------route to test if the process is running-------------------------------
@ -113,9 +110,11 @@ server.get('/baseline', bodyParser.json(), function(req, res) {
server.get('/scale', bodyParser.json(), function(req, res) { server.get('/scale', bodyParser.json(), function(req, res) {
var sql = ""; var sql = "";
var where = ""; //holds the where var w = ""; //holds the where
var check = 1; //flag if body is empty var c = 1; //flag if body is empty
var d = 1;
var path = './routes/scale/scale.sql'; var path = './routes/scale/scale.sql';
var args = [];
fs.readFile(path, 'utf8', function(err, data) { fs.readFile(path, 'utf8', function(err, data) {
@ -125,7 +124,7 @@ server.get('/scale', bodyParser.json(), function(req, res) {
return return
} }
({ c: check, w: where } = build_where(req, check, where)); let { check, where } = build_where(req, c, w, d, args);
//if there was no body sent, return with nothing //if there was no body sent, return with nothing
//if (c == 1) { //if (c == 1) {
// res.send("no body was sent"); // res.send("no body was sent");

View File

@ -1,4 +1,4 @@
# execure the sql for scale which builds the sql and inserts into a table # execure the sql for scale which builds the sql and inserts into a table
psql -h hptrow.me -p 54329 -d ubm -U ptrowbridge -f ./setup_sql/05_gen_scale.sql #$PG -f ./routes/scale/gen_scale.sql
# pull the sql out of the table and write it to route directory # pull the sql out of the table and write it to route directory
psql -h hptrow.me -p 54329 -d ubm -U ptrowbridge -c "SELECT t FROM fc.sql WHERE cmd = 'scale'" -t -A -o ./routes/scale/scale.sql psql -h hptrow.me -p 54329 -d ubm -U ptrowbridge -c "SELECT t FROM fc.sql WHERE cmd = 'scale'" -t -A -o ./routes/scale/scale.sql

View File

@ -140,7 +140,6 @@ FROM
WHERE WHERE
pscale.factor <> 0 or pscale.mod_price <> 0 pscale.factor <> 0 or pscale.mod_price <> 0
) )
,ins AS (
INSERT INTO INSERT INTO
fc.dcard fc.dcard
SELECT SELECT
@ -152,8 +151,4 @@ SELECT
* *
FROM FROM
pricing pricing
RETURNING *
)
SELECT count(*) num_rows FROM ins

View File

@ -245,7 +245,6 @@ FROM
WHERE WHERE
pscale.factor <> 0 or pscale.mod_price <> 0 pscale.factor <> 0 or pscale.mod_price <> 0
) )
,ins AS (
INSERT INTO INSERT INTO
$$||_target_table||$$ $$||_target_table||$$
SELECT SELECT
@ -257,10 +256,6 @@ SELECT
* *
FROM FROM
pricing pricing
RETURNING *
)
SELECT count(*) num_rows FROM ins
$$ $$
INTO INTO
_sql; _sql;