From 7cef794368c379bf118dcfe1cbe6a759a508cf6d Mon Sep 17 00:00:00 2001 From: Trowbridge Date: Wed, 27 Feb 2019 14:20:17 -0500 Subject: [PATCH] add route to get the main pool --- index.js | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/index.js b/index.js index bbc015a..fb5f5ff 100644 --- a/index.js +++ b/index.js @@ -85,6 +85,92 @@ server.get('/monthly_orders', bodyParser.json(), function (req,res) { //res.json("hi") }) +server.get('/get_pool', bodyParser.json(), function (req,res) { + + var args = [req.body.quota_rep]; + //------------------------------------------set base SQL------------------------------------ + var w = + ` + SELECT + ---------customer info----------------- + bill_cust_descr + ,billto_group + ,ship_cust_descr + ,shipto_group + ,quota_rep_descr + ,director_descr + ,segm + ,mod_chan + ,mod_chansub + ---------product info------------------ + ,majg_descr + ,ming_descr + ,majs_descr + ,mins_descr + ,brand + ,part_family + ,part_group + ,branding + ,color + ,part_descr + ---------dates------------------------- + ,order_season + ,order_month + ,ship_season + ,ship_month + ,request_season + ,request_month + ,promo + ,version + ,iter + --------values------------------------- + ,sum(value_loc) value_loc + ,sum(value_usd) value_usd + ,sum(cost_loc) cost_loc + ,sum(cost_usd) cost_usd + ,sum(units) units + FROM + rlarp.osm_fcpool + WHERE + quota_rep_descr = $1 + GROUP BY + ---------customer info----------------- + bill_cust_descr + ,billto_group + ,ship_cust_descr + ,shipto_group + ,quota_rep_descr + ,director_descr + ,segm + ,mod_chan + ,mod_chansub + ---------product info------------------ + ,majg_descr + ,ming_descr + ,majs_descr + ,mins_descr + ,brand + ,part_family + ,part_group + ,branding + ,color + ,part_descr + ---------dates------------------------- + ,order_season + ,order_month + ,ship_season + ,ship_month + ,request_season + ,request_month + ,promo + ,version + ,iter`; + //-----------------replace default quota_rep---------------------------------------------------- + console.log(w); + Postgres.FirstRow(w,args,res) + //res.json("hi") +}) + server.get('/', (req,res) => res.send('node.js express is running: 🎉')) server.listen(3000,() => console.log('started'))