Compare commits
	
		
			No commits in common. "834d52a2a2a7a8abd3454f857575c7f2cbae0813" and "ca996adac6ac720038f43df5bc83e4148e050be3" have entirely different histories.
		
	
	
		
			834d52a2a2
			...
			ca996adac6
		
	
		
							
								
								
									
										55
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								index.js
									
									
									
									
									
								
							@ -217,50 +217,6 @@ server.post('/swap', bodyParser.json(), function(req, res) {
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
server.post('/cust_swap', bodyParser.json(), function(req, res) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    var sql = "";
 | 
					 | 
				
			||||||
    var w = "";
 | 
					 | 
				
			||||||
    var c = 1;
 | 
					 | 
				
			||||||
    var d = 1;
 | 
					 | 
				
			||||||
    var args = [];
 | 
					 | 
				
			||||||
    var path = './route_sql/swap_cust.sql';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fs.readFile(path, 'utf8', function(err, data) {
 | 
					 | 
				
			||||||
        if (!err) {
 | 
					 | 
				
			||||||
            callback(data);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            console.log("fatal error pulling sql file")
 | 
					 | 
				
			||||||
            callback(err);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    var callback = function(arg) {
 | 
					 | 
				
			||||||
        sql = arg;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //parse request body into a where clause
 | 
					 | 
				
			||||||
        ({ c, w, d } = build_where(req, c, w, d, args));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //if there was no body sent, return with nothing
 | 
					 | 
				
			||||||
        if (c == 1) {
 | 
					 | 
				
			||||||
            res.send("no body was sent");
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        console.log(new Date().toISOString() + "-------------------------get swap fit:------------------------------")
 | 
					 | 
				
			||||||
        console.log(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("swap_doc", 'g'), JSON.stringify(req.body.swap));
 | 
					 | 
				
			||||||
        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));
 | 
					 | 
				
			||||||
        //execute the sql and send the result
 | 
					 | 
				
			||||||
        console.log(sql);
 | 
					 | 
				
			||||||
        res.json(null);
 | 
					 | 
				
			||||||
        //Postgres.FirstRow(sql, [], res)
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
server.get('/list_changes', bodyParser.json(), function(req, res) {
 | 
					server.get('/list_changes', bodyParser.json(), function(req, res) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var sql = "";
 | 
					    var sql = "";
 | 
				
			||||||
@ -282,19 +238,10 @@ server.get('/list_changes', bodyParser.json(), function(req, res) {
 | 
				
			|||||||
    var callback = function(arg) {
 | 
					    var callback = function(arg) {
 | 
				
			||||||
        sql = arg;
 | 
					        sql = arg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //parse request body into a where clause
 | 
					 | 
				
			||||||
        ({ c, w, d } = build_where(req, c, w, d, args));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //if there was no body sent, return with nothing
 | 
					 | 
				
			||||||
        if (c == 1) {
 | 
					 | 
				
			||||||
            res.send("no body was sent");
 | 
					 | 
				
			||||||
            return;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        console.log(new Date().toISOString() + "-------------------------list changes:------------------------------")
 | 
					        console.log(new Date().toISOString() + "-------------------------list changes:------------------------------")
 | 
				
			||||||
        console.log(req.body);
 | 
					        console.log(req.body);
 | 
				
			||||||
        //parse the where clause into the main sql statement
 | 
					        //parse the where clause into the main sql statement
 | 
				
			||||||
        sql = sql.replace(new RegExp("where_clause", 'g'), w)
 | 
					        sql = sql.replace(new RegExp("replace_user", 'g'), req.body.quota_rep_descr)
 | 
				
			||||||
            //execute the sql and send the result
 | 
					            //execute the sql and send the result
 | 
				
			||||||
        console.log(sql);
 | 
					        console.log(sql);
 | 
				
			||||||
        Postgres.FirstRow(sql, [], res)
 | 
					        Postgres.FirstRow(sql, [], res)
 | 
				
			||||||
 | 
				
			|||||||
@ -14,7 +14,7 @@ from
 | 
				
			|||||||
    inner join rlarp.osm_pool on
 | 
					    inner join rlarp.osm_pool on
 | 
				
			||||||
        id = logid
 | 
					        id = logid
 | 
				
			||||||
WHERE
 | 
					WHERE
 | 
				
			||||||
    where_clause
 | 
					    quota_rep_descr = 'replace_user'
 | 
				
			||||||
    AND tag <> 'Initial Build'
 | 
					    AND tag <> 'Initial Build'
 | 
				
			||||||
group BY
 | 
					group BY
 | 
				
			||||||
    ol.doc->>'user'
 | 
					    ol.doc->>'user'
 | 
				
			||||||
 | 
				
			|||||||
@ -17,17 +17,17 @@ target AS (SELECT $$swap_doc$$::jsonb swap)
 | 
				
			|||||||
    SELECT
 | 
					    SELECT
 | 
				
			||||||
        billto
 | 
					        billto
 | 
				
			||||||
        ,bill_r
 | 
					        ,bill_r
 | 
				
			||||||
        ,bc.bvadr6 bill_dba
 | 
					        ,bill_dba
 | 
				
			||||||
        ,shipto
 | 
					        ,shipto
 | 
				
			||||||
        ,ship_r
 | 
					        ,ship_r
 | 
				
			||||||
        ,sc.bvadr6 ship_dba
 | 
					        ,ship_dba
 | 
				
			||||||
        --other stuff doesn't matter becuase it's getting overridden anyways
 | 
					        --other stuff doesn't matter becuase it's getting overridden anyways
 | 
				
			||||||
    FROM
 | 
					    FROM
 | 
				
			||||||
        swap
 | 
					        swap
 | 
				
			||||||
        LEFT out JOIN lgdat.cust bc ON
 | 
					        LEFT out JOIN lgdat.cust bc ON
 | 
				
			||||||
            bc.bvcust = swap.bill_r
 | 
					            bc.bvcust = swap.bill_r
 | 
				
			||||||
        LEFT out JOIN lgdat.cust sc ON
 | 
					        LEFT out JOIN lgdat.cust sc ON
 | 
				
			||||||
            sc.bvcust = swap.ship_r
 | 
					            bc.bvcust = swap.ship_r
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
--put bill to and ship to back together and join in channel, terms, descriptions, etc
 | 
					--put bill to and ship to back together and join in channel, terms, descriptions, etc
 | 
				
			||||||
,seg AS (
 | 
					,seg AS (
 | 
				
			||||||
@ -112,9 +112,8 @@ target AS (SELECT $$swap_doc$$::jsonb swap)
 | 
				
			|||||||
    FROM
 | 
					    FROM
 | 
				
			||||||
        rlarp.osm_pool o
 | 
					        rlarp.osm_pool o
 | 
				
			||||||
        CROSS JOIN log
 | 
					        CROSS JOIN log
 | 
				
			||||||
        INNER JOIN swap ON
 | 
					        INNER JOIN pl ON
 | 
				
			||||||
            swap.bill_to = SUBSTRING(o.bill_cust_descr,1,8)
 | 
					            pl.original = o.part
 | 
				
			||||||
            swap.bill_to = SUBSTRING(o.ship_cust_descr,1,8)
 | 
					 | 
				
			||||||
    WHERE
 | 
					    WHERE
 | 
				
			||||||
        -----------------scenario----------------------------
 | 
					        -----------------scenario----------------------------
 | 
				
			||||||
        where_clause
 | 
					        where_clause
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user