clean up scenario package
This commit is contained in:
parent
aa67562d5b
commit
04b43a8f8d
10
index.js
10
index.js
@ -167,15 +167,11 @@ server.get('/scenario_package', bodyParser.json(), function (req, res) {
|
|||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
'months'
|
'months'
|
||||||
,(SELECT jsonb_agg(row_to_json(months)::jsonb) FROM months)
|
,(SELECT jsonb_agg(row_to_json(months)::jsonb) FROM months)
|
||||||
)
|
,'base'
|
||||||
,jsonb_build_object(
|
|
||||||
'base'
|
|
||||||
,(SELECT jsonb_agg(row_to_json(base)::jsonb) FROM base)
|
,(SELECT jsonb_agg(row_to_json(base)::jsonb) FROM base)
|
||||||
)
|
,'totals'
|
||||||
,jsonb_build_object(
|
|
||||||
'totals'
|
|
||||||
,(SELECT jsonb_agg(row_to_json(totals)::jsonb) FROM totals)
|
,(SELECT jsonb_agg(row_to_json(totals)::jsonb) FROM totals)
|
||||||
)`
|
) package`
|
||||||
console.log(w);
|
console.log(w);
|
||||||
Postgres.FirstRow(w, [], res)
|
Postgres.FirstRow(w, [], res)
|
||||||
//res.json("hi")
|
//res.json("hi")
|
||||||
|
@ -1,72 +1,68 @@
|
|||||||
--\timing
|
\timing
|
||||||
--explain (analyze, buffers)
|
--explain (analyze, buffers)
|
||||||
WITH base AS (
|
WITH base AS (
|
||||||
SELECT
|
SELECT
|
||||||
order_season
|
order_season
|
||||||
,order_month
|
,order_month
|
||||||
,version
|
,version
|
||||||
,iter
|
,iter
|
||||||
,part_descr
|
,part_descr
|
||||||
,bill_cust_descr
|
,bill_cust_descr
|
||||||
,ship_cust_descr
|
,ship_cust_descr
|
||||||
,SUM(units) units
|
,SUM(units) units
|
||||||
,SUM(value_usd) value_usd
|
,SUM(value_usd) value_usd
|
||||||
FROM
|
FROM
|
||||||
rlarp.osm_fcpool
|
rlarp.osm_fcpool
|
||||||
WHERE
|
WHERE
|
||||||
quota_rep_descr = '90005 - MARK WILKINSON'
|
quota_rep_descr = '90005 - MARK WILKINSON'
|
||||||
AND segm = 'Retail'
|
AND segm = 'Retail'
|
||||||
AND mod_chan = 'MASS'
|
AND mod_chan = 'MASS'
|
||||||
AND order_month = 'May'
|
AND order_month = 'May'
|
||||||
GROUP BY
|
GROUP BY
|
||||||
order_season
|
order_season
|
||||||
,order_month
|
,order_month
|
||||||
,version
|
,version
|
||||||
,iter
|
,iter
|
||||||
,part_descr
|
,part_descr
|
||||||
,bill_cust_descr
|
,bill_cust_descr
|
||||||
,ship_cust_descr
|
,ship_cust_descr
|
||||||
)
|
)
|
||||||
,months AS (
|
,months AS (
|
||||||
SELECT
|
SELECT
|
||||||
order_season
|
order_season
|
||||||
,version
|
,version
|
||||||
,iter
|
,iter
|
||||||
,order_month
|
,order_month
|
||||||
,sum(units) units
|
,sum(units) units
|
||||||
,sum(value_usd) value_usd
|
,sum(value_usd) value_usd
|
||||||
FROM
|
FROM
|
||||||
base
|
base
|
||||||
GROUP BY
|
GROUP BY
|
||||||
order_season
|
order_season
|
||||||
,version
|
,version
|
||||||
,iter
|
,iter
|
||||||
,order_month
|
,order_month
|
||||||
)
|
)
|
||||||
,totals AS (
|
,totals AS (
|
||||||
SELECT
|
SELECT
|
||||||
order_season
|
order_season
|
||||||
,version
|
,version
|
||||||
,iter
|
,iter
|
||||||
,sum(units) units
|
,sum(units) units
|
||||||
,sum(value_usd) value_usd
|
,sum(value_usd) value_usd
|
||||||
FROM
|
FROM
|
||||||
months
|
months
|
||||||
GROUP BY
|
GROUP BY
|
||||||
order_season
|
order_season
|
||||||
,version
|
,version
|
||||||
,iter
|
,iter
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
'months'
|
'months'
|
||||||
,(SELECT jsonb_agg(row_to_json(months)::jsonb) FROM months)
|
,(SELECT jsonb_agg(row_to_json(months)::jsonb) FROM months)
|
||||||
)
|
,'base'
|
||||||
,jsonb_build_object(
|
,(SELECT jsonb_agg(row_to_json(base)::jsonb) FROM base)
|
||||||
'base'
|
,'totals'
|
||||||
,(SELECT jsonb_agg(row_to_json(base)::jsonb) FROM base)
|
,(SELECT jsonb_agg(row_to_json(totals)::jsonb) FROM totals)
|
||||||
)
|
) package
|
||||||
,jsonb_build_object(
|
|
||||||
'totals'
|
|
||||||
,(SELECT jsonb_agg(row_to_json(totals)::jsonb) FROM totals)
|
|
||||||
)
|
|
Loading…
Reference in New Issue
Block a user