Compare commits
2 Commits
8aeecc845b
...
1b8c101429
Author | SHA1 | Date | |
---|---|---|---|
|
1b8c101429 | ||
|
6e8f026770 |
10
index.js
10
index.js
@ -157,9 +157,9 @@ 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'),JSON.stringify(req.body))
|
sql = sql.replace(new RegExp("replace_user", 'g'), JSON.stringify(req.body.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)
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
@ -480,13 +480,11 @@ function build_where(req, c, w, d, args) {
|
|||||||
d = d + 1;
|
d = d + 1;
|
||||||
}
|
}
|
||||||
w = w + ")";
|
w = w + ")";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
w = w + i + " = '" + req.body.scenario[i] + "'";
|
w = w + i + " = '" + req.body.scenario[i] + "'";
|
||||||
}
|
}
|
||||||
args.push(req.body.scenario[i]);
|
args.push(req.body.scenario[i]);
|
||||||
c = c + 1;
|
c = c + 1;
|
||||||
}
|
};
|
||||||
;
|
|
||||||
return { c, w, d };
|
return { c, w, d };
|
||||||
}
|
}
|
@ -1,21 +1,37 @@
|
|||||||
WITH
|
WITH
|
||||||
list AS (
|
list AS materialized (
|
||||||
SELECT
|
SELECT
|
||||||
iterdef->>'user' "user",
|
l.doc->>'user' "user",
|
||||||
iterdef->>'stamp' "stamp",
|
jsonb_path_query_first(l.doc,'$.scenario.quota_rep_descr')->>0 quota_rep_descr,
|
||||||
iterdef->>'mesasage' "comment",
|
to_char((l.doc->>'stamp')::timestamptz,'YYYY-MM-DD HH:MI:SS') "stamp",
|
||||||
round(SUM(fb_val_loc * r_rate)::numeric,2) sales,
|
l.doc->>'message' "comment",
|
||||||
jsonb_pretty(iterdef) def
|
jsonb_pretty(l.doc) def,
|
||||||
|
l.id
|
||||||
FROM
|
FROM
|
||||||
rlarp.osm_fcpool
|
rlarp.osm_log l
|
||||||
WHERE
|
WHERE
|
||||||
iterdef IS NOT NULL
|
l.doc @? '$.scenario.quota_rep_descr ? (@ == replace_user)'
|
||||||
AND iterdef @> $$replace_user$$::jsonb
|
)
|
||||||
GROUP BY
|
,agg as (
|
||||||
iterdef->>'user',
|
SELECT
|
||||||
iterdef->>'stamp',
|
list.user
|
||||||
iterdef->>'message',
|
,list.quota_rep_descr
|
||||||
iterdef
|
,list.stamp
|
||||||
|
,list.comment
|
||||||
|
,list.def
|
||||||
|
,list.id
|
||||||
|
,to_char(round(sum(value_usd),2),'$999,999,999D00') sales
|
||||||
|
from
|
||||||
|
LIST
|
||||||
|
inner join rlarp.osm_pool on
|
||||||
|
id = logid
|
||||||
|
group BY
|
||||||
|
list.user
|
||||||
|
,list.quota_rep_descr
|
||||||
|
,list.stamp
|
||||||
|
,list.comment
|
||||||
|
,list.def
|
||||||
|
,list.id
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
jsonb_agg(row_to_json(list)::jsonb) x from list
|
jsonb_agg(row_to_json(agg)::jsonb ORDER BY agg.stamp desc) x from agg
|
@ -254,9 +254,9 @@ SELECT
|
|||||||
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 + 2021,mxm.cal,mxm.odom)
|
||||||
LEFT OUTER JOIN gld rd ON
|
LEFT OUTER JOIN gld rd ON
|
||||||
od.drange @> (make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag)
|
rd.drange @> (make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag)
|
||||||
LEFT OUTER JOIN gld sd ON
|
LEFT OUTER JOIN gld sd ON
|
||||||
od.drange @> (make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag + slag)
|
sd.drange @> (make_date(mxm.yr + 2021,mxm.cal,mxm.odom) + rlag + slag)
|
||||||
)
|
)
|
||||||
--SELECT * FROM basemix
|
--SELECT * FROM basemix
|
||||||
,log AS (
|
,log AS (
|
||||||
|
Loading…
Reference in New Issue
Block a user