pick the next closest month if not avilable
This commit is contained in:
parent
71c873bc20
commit
69766c6f42
26
index.js
26
index.js
@ -451,6 +451,15 @@ server.get('/addmonth_v', bodyParser.json(), function (req, res) {
|
|||||||
FROM
|
FROM
|
||||||
mmix
|
mmix
|
||||||
)
|
)
|
||||||
|
,closest AS (
|
||||||
|
SELECT
|
||||||
|
_month
|
||||||
|
FROM
|
||||||
|
mmixp
|
||||||
|
ORDER BY
|
||||||
|
abs(seq - (select s from mseq where m = '` + req.body.month + `' )) ASC
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
--SELECT * FROM mmixp order by seq asc, vperc desc
|
--SELECT * FROM mmixp order by seq asc, vperc desc
|
||||||
,basemix AS (
|
,basemix AS (
|
||||||
SELECT
|
SELECT
|
||||||
@ -760,7 +769,7 @@ server.get('/addmonth_v', bodyParser.json(), function (req, res) {
|
|||||||
LEFT OUTER JOIN gld sd ON
|
LEFT OUTER JOIN gld sd ON
|
||||||
make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||||
WHERE
|
WHERE
|
||||||
m._month = '` + req.body.month + `'
|
m._month = (SELECT _month FROM closest)
|
||||||
)
|
)
|
||||||
, ins AS (
|
, ins AS (
|
||||||
INSERT INTO rlarp.osm_fcpool SELECT * FROM final RETURNING *
|
INSERT INTO rlarp.osm_fcpool SELECT * FROM final RETURNING *
|
||||||
@ -834,7 +843,7 @@ server.get('/addmonth_v', bodyParser.json(), function (req, res) {
|
|||||||
)
|
)
|
||||||
SELECT json_agg(row_to_json(insagg)) x from insagg
|
SELECT json_agg(row_to_json(insagg)) x from insagg
|
||||||
`
|
`
|
||||||
//console.log(w);
|
console.log(w);
|
||||||
console.log(req.body);
|
console.log(req.body);
|
||||||
Postgres.FirstRow(w, [], res)
|
Postgres.FirstRow(w, [], res)
|
||||||
//res.json(w)
|
//res.json(w)
|
||||||
@ -995,6 +1004,15 @@ server.get('/addmonth_vp', bodyParser.json(), function (req, res) {
|
|||||||
FROM
|
FROM
|
||||||
mmix
|
mmix
|
||||||
)
|
)
|
||||||
|
,closest AS (
|
||||||
|
SELECT
|
||||||
|
_month
|
||||||
|
FROM
|
||||||
|
mmixp
|
||||||
|
ORDER BY
|
||||||
|
abs(seq - (select s from mseq where m = '` + req.body.month + `' )) ASC
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
--SELECT * FROM mmixp order by seq asc, vperc desc
|
--SELECT * FROM mmixp order by seq asc, vperc desc
|
||||||
,basemix AS (
|
,basemix AS (
|
||||||
SELECT
|
SELECT
|
||||||
@ -1304,7 +1322,7 @@ server.get('/addmonth_vp', bodyParser.json(), function (req, res) {
|
|||||||
LEFT OUTER JOIN gld sd ON
|
LEFT OUTER JOIN gld sd ON
|
||||||
make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||||
WHERE
|
WHERE
|
||||||
m._month = '` + req.body.month + `'
|
m._month = (SELECT _month FROM closest)
|
||||||
)
|
)
|
||||||
,pscale AS (
|
,pscale AS (
|
||||||
SELECT
|
SELECT
|
||||||
@ -1497,7 +1515,7 @@ server.get('/addmonth_vp', bodyParser.json(), function (req, res) {
|
|||||||
,iter
|
,iter
|
||||||
)
|
)
|
||||||
SELECT json_agg(row_to_json(insagg)) x from insagg`
|
SELECT json_agg(row_to_json(insagg)) x from insagg`
|
||||||
//console.log(w);
|
console.log(w);
|
||||||
console.log(req.body);
|
console.log(req.body);
|
||||||
Postgres.FirstRow(w, [], res)
|
Postgres.FirstRow(w, [], res)
|
||||||
//res.json(w)
|
//res.json(w)
|
||||||
|
@ -124,6 +124,15 @@ target AS (select -50000 vincr, 20000 pincr)
|
|||||||
FROM
|
FROM
|
||||||
mmix
|
mmix
|
||||||
)
|
)
|
||||||
|
,closest AS (
|
||||||
|
SELECT
|
||||||
|
_month
|
||||||
|
FROM
|
||||||
|
mmixp
|
||||||
|
ORDER BY
|
||||||
|
abs(seq - (select s from mseq where m = 'Jul' )) ASC
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
--SELECT * FROM mmixp order by seq asc, vperc desc
|
--SELECT * FROM mmixp order by seq asc, vperc desc
|
||||||
,basemix AS (
|
,basemix AS (
|
||||||
SELECT
|
SELECT
|
||||||
@ -437,7 +446,7 @@ FROM
|
|||||||
LEFT OUTER JOIN gld sd ON
|
LEFT OUTER JOIN gld sd ON
|
||||||
make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||||
WHERE
|
WHERE
|
||||||
m._month = 'Jul'
|
m._month = (SELECT _month FROM closest)
|
||||||
)
|
)
|
||||||
,pscale AS (
|
,pscale AS (
|
||||||
SELECT
|
SELECT
|
||||||
|
Loading…
Reference in New Issue
Block a user