Skip to content

Commit

Permalink
Minor updates for API calls (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman authored Oct 24, 2023
1 parent 27def3c commit 386054b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions API/Backend/Geodatasets/routes/geodatasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ router.post("/recreate", function (req, res, next) {
body: {},
});
}
if (!features) {
//Must be a single feature from an append. Make an array
features = [JSON.parse(req.body.geojson)];
}

makeNewGeodatasetTable(
req.body.name,
Expand All @@ -325,8 +329,13 @@ router.post("/recreate", function (req, res, next) {
return;
}

let drop_qry = "TRUNCATE TABLE " + result.table + " RESTART IDENTITY";
if (req.body.hasOwnProperty("action") && req.body.action=="append") {
drop_qry = "";
}

sequelize
.query("TRUNCATE TABLE " + result.table + " RESTART IDENTITY")
.query(drop_qry)
.then(() => {
populateGeodatasetTable(
result.tableObj,
Expand All @@ -343,7 +352,7 @@ router.post("/recreate", function (req, res, next) {
return null;
})
.catch((err) => {
logger("error", "Recreation error.", req.originalUrl, req, err);
logger("error", "Recreation error.", req.originalUrl, req, err.stack);
res.send(result);
});
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ function ensureAdmin(toLoginPage, denyLongTermTokens) {
}

function validateLongTermToken(token, successCallback, failureCallback) {
token = token.replace("Bearer ", "");
token = token.replace(/Bearer:?\s+/g, "");

sequelize
.query('SELECT * FROM "long_term_tokens" WHERE "token"=:token', {
Expand Down

0 comments on commit 386054b

Please sign in to comment.