Skip to content

Commit 85f6acf

Browse files
committed
fixed mobile/points endpoint
1 parent 7bfea3c commit 85f6acf

File tree

8 files changed

+20
-19
lines changed

8 files changed

+20
-19
lines changed

api-tests/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as fs from "fs";
1010
import * as path from "path";
1111
/*
1212
const endpointsToFix = [
13-
//can't find the gmna.lookup_units table. 'geologic_units_gmna.ts',
13+
//can't find the gmna.lookup_units table. 'geologic_units_gmna.ts' Reached out to Shanan to see if we're going to migrate the geomacro db or if i need to rewrite this endpoint.
1414
//'geologic_units_gmus.ts'
1515
//'mancos_test_cases.ts',
1616
//uses gmus.lookup_units table. queries need to be customized and changed to match all of the lookup tables within postgresql

api-tests/v2Tests/defs_econs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ var request = require("supertest"),
33
settings = require("../settings");
44

55
it("should return metadata", function (done) {
6-
request(settings.host)
6+
this.timeout(10000);
7+
request(settings.host)
78
.get("/defs/econs")
89
.expect(validators.aSuccessfulRequest)
910
.expect(validators.json)

api-tests/v2Tests/units.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ it("should accept a environ_type parameter", function (done) {
204204
});
205205

206206
it("should accept a environ_class parameter", function (done) {
207-
this.timeout(10000);
207+
this.timeout(15000);
208208
request(settings.host)
209209
.get("/units?environ_class=marine")
210210
.expect(validators.aSuccessfulRequest)
@@ -224,7 +224,8 @@ it("should accept a environ_class parameter", function (done) {
224224
});
225225

226226
it("should accept a project_id", function (done) {
227-
request(settings.host)
227+
this.timeout(15000);
228+
request(settings.host)
228229
.get("/units?project_id=4")
229230
.expect(validators.aSuccessfulRequest)
230231
.expect(validators.json)

v2/geologic_units_gmna.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ module.exports = function (req, res, next) {
99
if (Object.keys(req.query).length < 1) {
1010
larkin.info(req, res, next);
1111
} else {
12+
13+
const hasSample = Object.prototype.hasOwnProperty.call(req.query, "sample");
14+
1215
var geo =
1316
req.query.format && api.acceptedFormats.geo[req.query.format]
1417
? true
@@ -19,11 +22,8 @@ module.exports = function (req, res, next) {
1922
geomField = geo ? ", ST_AsGeoJSON(geom) AS geometry" : "",
2023
limit,
2124
from = "";
22-
if (req.query.sample === "") {
23-
limit = " LIMIT 5";
24-
} else {
25-
limit = "";
26-
}
25+
26+
limit = hasSample ? " LIMIT 5" : "";
2727

2828
if (req.query.gid && req.query.gid != "undefined") {
2929
where.push(" gid = $" + (where.length + 1));
@@ -76,23 +76,24 @@ module.exports = function (req, res, next) {
7676
? ", ST_AsGeoJSON(ST_Intersection(ST_Buffer(geom, 0)::geography, buffer)) AS geometry"
7777
: "";
7878
}
79-
80-
if (where.length < 1 && !req.query.sample) {
79+
if (where.length < 1 && !hasSample) {
8180
return larkin.error(req, res, next, "Invalid params");
8281
}
8382

8483
if (where.length > 0) {
8584
where = " WHERE " + where.join(", ");
8685
}
87-
//todo modify query to use macrostrat schema.
88-
larkin.queryPg(
89-
"geomacro",
90-
"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" +
86+
87+
let sql = "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" +
9188
geomField +
9289
" FROM gmna.lookup_units" +
9390
from +
9491
where +
95-
limit,
92+
limit
93+
//todo modify query to use macrostrat schema.
94+
larkin.queryPg(
95+
"geomacro",
96+
sql,
9697
params,
9798
function (error, result) {
9899
if (error) {

v2/geologic_units_gmus.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ module.exports = function (req, res, next) {
234234
where +
235235
orderBy +
236236
limit;
237-
238237
larkin.queryPg("geomacro", sql, params, function (error, result) {
239238
if (error) {
240239
larkin.error(req, res, next, error);

v2/mobile/point.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function buildSQL(scale, where) {
4242
LEFT JOIN maps.map_liths ON map_liths.map_id = m.map_id
4343
LEFT JOIN macrostrat.liths ON map_liths.lith_id = liths.id
4444
${where}
45-
GROUP BY m.map_id
45+
GROUP BY m.map_id, m.source_id, m.name, m.age, m.strat_name, m.lith, m.descrip, m.comments
4646
)
4747
`;
4848
}
@@ -71,7 +71,6 @@ module.exports = function (req, res, next) {
7171
.join(" UNION ");
7272

7373
var toRun = `SELECT * FROM ( ${scaleSQL} ) doit`;
74-
7574
larkin.queryPg("burwell", toRun, params, function (error, result) {
7675
if (error || !result.rows || !result.rows.length) {
7776
return callback(null, {});

0 commit comments

Comments
 (0)