From e3205a94c1e1d13027320eed989f749d4cb913ef Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 2 Apr 2020 09:55:53 -0400 Subject: [PATCH] setup history listing to be based on a where clause to allow for director level --- index.js | 11 ++++++++++- route_sql/list_changes.sql | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c4636e3..b8e7ae0 100644 --- a/index.js +++ b/index.js @@ -238,10 +238,19 @@ server.get('/list_changes', bodyParser.json(), function(req, res) { var callback = function(arg) { sql = arg; + //parse request body into a where clause + ({ c, w, d } = build_where(req, c, w, d, args)); + + + //if there was no body sent, return with nothing + if (c == 1) { + res.send("no body was sent"); + return; + } console.log(new Date().toISOString() + "-------------------------list changes:------------------------------") console.log(req.body); //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("where_clause", 'g'), w) //execute the sql and send the result console.log(sql); Postgres.FirstRow(sql, [], res) diff --git a/route_sql/list_changes.sql b/route_sql/list_changes.sql index b00a269..a8f4589 100644 --- a/route_sql/list_changes.sql +++ b/route_sql/list_changes.sql @@ -14,7 +14,7 @@ from inner join rlarp.osm_pool on id = logid WHERE - quota_rep_descr = 'replace_user' + where_clause AND tag <> 'Initial Build' group BY ol.doc->>'user'