From ecaef0ae4b1acc11a6b8b190103fd2338bd41f35 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Mon, 18 Mar 2019 17:27:01 -0400 Subject: [PATCH] setup a basket to send back, convert to https --- .gitignore | 1 + index.js | 11 ++++++++++- route_sql/scenario_package.sql | 36 ++++++++++++++++++++++++---------- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 7229936..7c4938e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ npm-debug.log /.vscode logs.html stat.html +*.pem diff --git a/index.js b/index.js index 9e1f754..da6b600 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ require('dotenv').config(); const express = require('express'); +var https = require('https'); var bodyParser = require('body-parser'); const server = express(); const pg = require('pg'); @@ -9,6 +10,15 @@ var fs = require('fs'); var readline = require('readline'); //------------------------------------------------------- +var options = { + key: fs.readFileSync('./key.pem'), + cert: fs.readFileSync('./cert.pem'), + passprase: [] +}; + +https.createServer(options,server).listen(3000, () => console.log('started')); +//server.listen(3000, () => console.log('started')) + var Postgres = new pg.Client({ user: process.env.user, password: process.env.password, @@ -353,4 +363,3 @@ function build_where(req, c, w, d, args) { return { c, w, d }; } -server.listen(3000, () => console.log('started')) diff --git a/route_sql/scenario_package.sql b/route_sql/scenario_package.sql index a7a49dd..fa5414c 100644 --- a/route_sql/scenario_package.sql +++ b/route_sql/scenario_package.sql @@ -23,10 +23,10 @@ mseq AS ( --select * from mseq ,base AS ( SELECT - --order_season - --,order_month - --,version - --,iter + order_season + ,order_month + ,version + ,iter ,part_descr ,bill_cust_descr ,ship_cust_descr @@ -37,14 +37,30 @@ FROM WHERE where_clause GROUP BY - --order_season - --,order_month - --,version - --,iter + order_season + ,order_month + ,version + ,iter ,part_descr ,bill_cust_descr ,ship_cust_descr ) +, basket AS ( + SELECT + part_descr + ,bill_cust_descr + ,ship_cust_descr + ,SUM(units) units + ,SUM(value_usd) value_usd + FROM + base + GROUP BY + part_descr + ,bill_cust_descr + ,ship_cust_descr + ORDER BY + value_usd desc +) ,months AS ( SELECT order_season @@ -123,8 +139,8 @@ SELECT ,(SELECT jsonb_agg(row_to_json(months)::jsonb) FROM months) ,'mpvt' ,(SELECT jsonb_agg(row_to_json(mlist)::jsonb) FROM mlist) - ,'base' - ,(SELECT jsonb_agg(row_to_json(base)::jsonb) FROM base) + ,'basket' + ,(SELECT jsonb_agg(row_to_json(basket)::jsonb) FROM basket) ,'totals' ,(SELECT jsonb_agg(row_to_json(totals)::jsonb) FROM totals) ) package \ No newline at end of file