Skip to content

Commit

Permalink
polishing up the last endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
amyfromandi committed Oct 30, 2024
1 parent 325ea35 commit 65b58ec
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
3 changes: 1 addition & 2 deletions api-tests/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +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_gmna.ts',
'geologic_units_gmna.ts',
//'geologic_units_gmus.ts'
//'mancos_test_cases.ts',
//'mobile_macro_summary.ts',
Expand Down
2 changes: 1 addition & 1 deletion v2/definitions/strat_names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function (req, res, next, cb) {
params["strat_name"] = req.query.strat_name;
} else if (req.query.strat_name_id) {
where.push(
"parent IN (:strat_name_id) OR l.strat_name_id = ANY(:strat_name_id)",
"parent = ANY(:strat_name_id) OR l.strat_name_id = ANY(:strat_name_id)",
);
params["strat_name_id"] = larkin.parseMultipleIds(
req.query.strat_name_id,
Expand Down
1 change: 0 additions & 1 deletion v2/geologic_units_burwell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ module.exports = function (req, res, next, cb) {
where = "";
}

console.log(req.query.scale)
if (req.query.scale) {
var requestedScales = larkin.parseMultipleStrings(req.query.scale);
var scales = requestedScales.filter(function (d) {
Expand Down
11 changes: 8 additions & 3 deletions v2/geologic_units_gmna.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ module.exports = function (req, res, next) {

var where = [],
params = [],
limit = "sample" in req.query ? " LIMIT 5" : "",
geomField = geo ? ", ST_AsGeoJSON(geom) AS geometry" : "",
limit,
from = "";
if (req.query.sample === "") {
limit = " LIMIT 5";
} else {
limit = "";
}

if (req.query.gid && req.query.gid != "undefined") {
where.push(" gid = $" + (where.length + 1));
Expand Down Expand Up @@ -72,14 +77,14 @@ module.exports = function (req, res, next) {
: "";
}

if (where.length < 1 && !("sample" in req.query)) {
if (where.length < 1 && !(req.query.sample)) {
return larkin.error(req, res, next, "Invalid params");
}

if (where.length > 0) {
where = " WHERE " + where.join(", ");
}

//todo modify query to use macrostrat schema.
larkin.queryPg(
"geomacro",
"SELECT gid, unit_abbre, COALESCE(rocktype, '') AS rocktype, COALESCE(lithology, '') AS lith, lith_type, lith_class, min_interval AS t_interval, min_age::float AS t_age, max_interval AS b_interval, max_age::float AS b_age, containing_interval, interval_color AS color" +
Expand Down
10 changes: 8 additions & 2 deletions v2/geologic_units_gmus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ module.exports = function (req, res, next) {

var where = [],
params = [],
limit = "sample" in req.query ? " LIMIT 5" : "",
limit,
from =
"gmus.lookup_units lu JOIN gmus.ages a ON lu.unit_link = a.unit_link LEFT JOIN gmus.liths l ON lu.unit_link = l.unit_link LEFT JOIN gmus.best_geounits_macrounits gm ON lu.gid = gm.geologic_unit_gid",
geomQuery = geo ? ", ST_AsGeoJSON(geom) AS geometry" : "",
orderBy = "";

if (req.query.sample === "") {
limit = " LIMIT 5";
} else {
limit = "";
}

async.parallel(
[
function (callback) {
Expand Down Expand Up @@ -194,7 +200,7 @@ module.exports = function (req, res, next) {
},
],
function () {
if (where.length < 1 && !("sample" in req.query)) {
if (where.length < 1 && !(req.query.sample)) {
return larkin.error(req, res, next, "Invalid params");
}

Expand Down

0 comments on commit 65b58ec

Please sign in to comment.