Merge branch 'dustoff' of github.com:The-HC-Companies/forecast_api into dustoff

This commit is contained in:
Paul Trowbridge 2021-04-06 08:35:59 -04:00
commit 4acee798d2
6 changed files with 23 additions and 23 deletions

View File

@ -7,7 +7,7 @@ ExecStart=/usr/bin/node //opt/forecast_api/index.js
Restart=always Restart=always
User=fc_api User=fc_api
Environemnt=NODE_ENV=production Environemnt=NODE_ENV=production
WorkingDirectory=//opt/forecast_api WorkingDirectory=//opt/forecast_api/
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -241,7 +241,7 @@ server.get('/list_changes', bodyParser.json(), function(req, res) {
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("replace_user", 'g'), req.body.quota_rep_descr) sql = sql.replace(new RegExp("replace_user", 'g'), req.body.scenario.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)

View File

@ -323,14 +323,14 @@ SELECT
,b.cost_usd*s.factor*m.momix cost_usd ,b.cost_usd*s.factor*m.momix cost_usd
,b.calc_status ,b.calc_status
,b.flag ,b.flag
,make_date(mseq.yr + 2021,mseq.cal,m.odom) order_date ,make_date(mseq.yr + 2022,mseq.cal,m.odom) order_date
,od.sspr || ' - ' || to_char(make_date(mseq.yr + 2021,mseq.cal,m.odom),'Mon') order_month ,od.sspr || ' - ' || to_char(make_date(mseq.yr + 2022,mseq.cal,m.odom),'Mon') order_month
,od.ssyr order_season ,od.ssyr order_season
,make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag request_date ,make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag request_date
,rd.sspr || ' - ' ||to_char(make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag,'Mon') request_month ,rd.sspr || ' - ' ||to_char(make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag,'Mon') request_month
,rd.ssyr request_season ,rd.ssyr request_season
,make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag + slag ship_date ,make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag + slag ship_date
,sd.sspr || ' - ' || to_char(make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag + slag,'Mon') ship_month ,sd.sspr || ' - ' || to_char(make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag + slag,'Mon') ship_month
,sd.ssyr ship_season ,sd.ssyr ship_season
,'replace_version' "version" ,'replace_version' "version"
,'replace_source'||' volume' iter ,'replace_source'||' volume' iter
@ -347,11 +347,11 @@ FROM
LEFT OUTER JOIN mseq ON LEFT OUTER JOIN mseq ON
mseq.m = closest.m mseq.m = closest.m
LEFT OUTER JOIN gld od ON LEFT OUTER JOIN gld od ON
make_date(mseq.yr + 2021,mseq.cal,m.odom) BETWEEN od.sdat AND od.edat make_date(mseq.yr + 2022,mseq.cal,m.odom) BETWEEN od.sdat AND od.edat
LEFT OUTER JOIN gld rd ON LEFT OUTER JOIN gld rd ON
make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag BETWEEN rd.sdat AND rd.edat make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag BETWEEN rd.sdat AND rd.edat
LEFT OUTER JOIN gld sd ON LEFT OUTER JOIN gld sd ON
make_date(mseq.yr + 2021,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat make_date(mseq.yr + 2022,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
WHERE WHERE
m._month = (SELECT _month FROM closest) m._month = (SELECT _month FROM closest)
) )
@ -520,4 +520,4 @@ FROM
,tag ,tag
,comment ,comment
) )
SELECT json_agg(row_to_json(insagg)) x from insagg SELECT json_agg(row_to_json(insagg)) x from insagg

View File

@ -19,7 +19,7 @@ FROM
LEFT OUTER JOIN rlarp.osm_log ON LEFT OUTER JOIN rlarp.osm_log ON
id = logid id = logid
WHERE WHERE
order_season = 2021 order_season = 2022
GROUP BY GROUP BY
director director
,quota_rep_descr ,quota_rep_descr
@ -51,4 +51,4 @@ GROUP BY
) )
ORDER BY ORDER BY
director director
,quota_rep_descr ,quota_rep_descr

View File

@ -250,13 +250,13 @@ SELECT
,substring(jr.part_descr,1,8) part_group ,substring(jr.part_descr,1,8) part_group
,mxm.qty*mxm.momix*jr.mix units ,mxm.qty*mxm.momix*jr.mix units
,mxm.amount*mxm.momix*jr.mix value_usd --assume that target dollars are USD ,mxm.amount*mxm.momix*jr.mix value_usd --assume that target dollars are USD
,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) order_date ,make_date(mxm.yr + 2022,mxm.cal,mxm.odom) order_date
,od.sortmo order_month ,od.sortmo order_month
,od.ssyr order_season ,od.ssyr order_season
,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag request_date ,make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag request_date
,rd.sortmo request_month ,rd.sortmo request_month
,rd.ssyr request_season ,rd.ssyr request_season
,make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag + slag ship_date ,make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag + slag ship_date
,sd.sortmo ship_month ,sd.sortmo ship_month
,sd.ssyr ship_season ,sd.ssyr ship_season
,jr.mix ,jr.mix
@ -266,11 +266,11 @@ SELECT
JOIN LATERAL json_to_record(ae.e) as jr(part_descr text, bill_cust_descr text, ship_cust_descr text, mix numeric) ON true JOIN LATERAL json_to_record(ae.e) as jr(part_descr text, bill_cust_descr text, ship_cust_descr text, mix numeric) ON true
CROSS JOIN mxm CROSS JOIN mxm
LEFT OUTER JOIN gld od ON LEFT OUTER JOIN gld od ON
od.drange @> make_date(mxm.yr + 2021,mxm.cal,mxm.odom) od.drange @> make_date(mxm.yr + 2022,mxm.cal,mxm.odom)
LEFT OUTER JOIN gld rd ON LEFT OUTER JOIN gld rd ON
rd.drange @> (make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag) rd.drange @> (make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag)
LEFT OUTER JOIN gld sd ON LEFT OUTER JOIN gld sd ON
sd.drange @> (make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag + slag) sd.drange @> (make_date(mxm.yr + 2022,mxm.cal,mxm.odom) + rlag + slag)
) )
--SELECT * FROM basemix --SELECT * FROM basemix
,log AS ( ,log AS (
@ -517,4 +517,4 @@ FROM
,tag ,tag
,comment ,comment
) )
SELECT json_agg(row_to_json(insagg)) x from insagg SELECT json_agg(row_to_json(insagg)) x from insagg

View File

@ -88,7 +88,7 @@ target AS (select target_vol vincr, target_prc pincr)
WHERE WHERE
-----------------scenario---------------------------- -----------------scenario----------------------------
where_clause where_clause
AND ship_season = 2021 AND ship_season = 2022
-----------------additional params------------------- -----------------additional params-------------------
AND CASE (SELECT flag FROM flagv) AND CASE (SELECT flag FROM flagv)
WHEN 'scale all' THEN true WHEN 'scale all' THEN true