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
|
||||
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
|
||||
,basemix AS (
|
||||
SELECT
|
||||
@ -760,7 +769,7 @@ server.get('/addmonth_v', bodyParser.json(), function (req, res) {
|
||||
LEFT OUTER JOIN gld sd ON
|
||||
make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||
WHERE
|
||||
m._month = '` + req.body.month + `'
|
||||
m._month = (SELECT _month FROM closest)
|
||||
)
|
||||
, ins AS (
|
||||
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
|
||||
`
|
||||
//console.log(w);
|
||||
console.log(w);
|
||||
console.log(req.body);
|
||||
Postgres.FirstRow(w, [], res)
|
||||
//res.json(w)
|
||||
@ -995,6 +1004,15 @@ server.get('/addmonth_vp', bodyParser.json(), function (req, res) {
|
||||
FROM
|
||||
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
|
||||
,basemix AS (
|
||||
SELECT
|
||||
@ -1304,7 +1322,7 @@ server.get('/addmonth_vp', bodyParser.json(), function (req, res) {
|
||||
LEFT OUTER JOIN gld sd ON
|
||||
make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||
WHERE
|
||||
m._month = '` + req.body.month + `'
|
||||
m._month = (SELECT _month FROM closest)
|
||||
)
|
||||
,pscale AS (
|
||||
SELECT
|
||||
@ -1497,7 +1515,7 @@ server.get('/addmonth_vp', bodyParser.json(), function (req, res) {
|
||||
,iter
|
||||
)
|
||||
SELECT json_agg(row_to_json(insagg)) x from insagg`
|
||||
//console.log(w);
|
||||
console.log(w);
|
||||
console.log(req.body);
|
||||
Postgres.FirstRow(w, [], res)
|
||||
//res.json(w)
|
||||
|
@ -124,6 +124,15 @@ target AS (select -50000 vincr, 20000 pincr)
|
||||
FROM
|
||||
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
|
||||
,basemix AS (
|
||||
SELECT
|
||||
@ -437,7 +446,7 @@ FROM
|
||||
LEFT OUTER JOIN gld sd ON
|
||||
make_date(mseq.yr + 2020,mseq.cal,m.odom) + rlag + slag BETWEEN sd.sdat AND sd.edat
|
||||
WHERE
|
||||
m._month = 'Jul'
|
||||
m._month = (SELECT _month FROM closest)
|
||||
)
|
||||
,pscale AS (
|
||||
SELECT
|
||||
|
Loading…
Reference in New Issue
Block a user