Skip to content

Commit

Permalink
fixed almost all of the geologic_units/burwell endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
amyfromandi committed Oct 29, 2024
1 parent 259ee09 commit 325ea35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api-tests/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as path from 'path';

const testFiles = [
// waiting for confirmation to implement solution for 'defs_sources.ts',
//'geologic_units_burwell.ts',
'geologic_units_burwell.ts',
//'geologic_units_gmna.ts',
//'geologic_units_gmus.ts'
//'mancos_test_cases.ts',
Expand Down
10 changes: 6 additions & 4 deletions v2/geologic_units_burwell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ module.exports = function (req, res, next, cb) {
var where = [],
params = [],
limit;

if ("sample" in req.query) {
if (req.query.sample === "") {
limit = " LIMIT 5";
req.query.scale = "medium";
} else {
Expand Down Expand Up @@ -171,7 +170,7 @@ module.exports = function (req, res, next, cb) {
],
function () {
// If no valid parameters passed, return an Error
if (where.length < 1 && !("sample" in req.query)) {
if (where.length < 1 && (req.query.sample === undefined)) {
if (cb) return cb("No valid parameters passed");
return larkin.error(req, res, next, "No valid parameters passed");
}
Expand All @@ -182,9 +181,10 @@ module.exports = function (req, res, next, cb) {
where = "";
}

console.log(req.query.scale)
if (req.query.scale) {
var requestedScales = larkin.parseMultipleStrings(req.query.scale);
scales = requestedScales.filter(function (d) {
var scales = requestedScales.filter(function (d) {
if (["tiny", "small", "medium", "large"].indexOf(d) > -1) {
return d;
}
Expand All @@ -209,6 +209,7 @@ module.exports = function (req, res, next, cb) {
.join(" UNION ");

var toRun = "SELECT * FROM ( " + scaleSQL + ") doit";
console.log(toRun)

larkin.queryPg("burwell", toRun, params, function (error, result) {
if (error) {
Expand Down Expand Up @@ -256,6 +257,7 @@ module.exports = function (req, res, next, cb) {
);
} else {
if (cb) return cb(null, result.rows);
console.log(result)
larkin.sendData(
req,
res,
Expand Down

0 comments on commit 325ea35

Please sign in to comment.