Skip to content

Commit

Permalink
fixed paleogeography endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
amyfromandi committed Nov 4, 2024
1 parent 65b58ec commit 7b16afc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions api-tests/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import * as path from 'path';

const testFiles = [
// waiting for confirmation to implement solution for 'defs_sources.ts',
'geologic_units_gmna.ts',
//'geologic_units_gmna.ts',
//'geologic_units_gmus.ts'
//'mancos_test_cases.ts',
//'mobile_macro_summary.ts',
//'mobile_map_query.ts',
//'mobile_point_details.ts',
//'paleogeography.ts',
'paleogeography.ts',
//'tiles.ts', need to test on dev url
// 'units.ts'
];
Expand Down
2 changes: 2 additions & 0 deletions v2/larkin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ const { Client, Pool } = require("pg");
//named uses yesql to modify the params dict and sql named parameters into an array before querying PG.
//client.query can only accept numerical indices in sql syntax and an array for parameter values.
const preparedQuery = named(sql)(params);
console.log("Yesql parsed query: ", preparedQuery.text);
console.log("Yesql parsed parameters: ", preparedQuery.values);
client.query(preparedQuery.text, preparedQuery.values, function (err, result) {
done();
if (err) {
Expand Down
13 changes: 7 additions & 6 deletions v2/paleogeography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ module.exports = function (req, res, next) {
if (req.query.age) {
callback(null, req.query.age);
} else if (req.query.interval_name) {
let sql = `SELECT (age_bottom + age_top)/2 AS mid FROM macrostrat.intervals WHERE interval_name = :interval_name`
params['interval_name'] = req.query.interval_name
let sql = `SELECT (age_bottom + age_top)/2 AS mid FROM macrostrat.intervals WHERE interval_name = :interval_name`;
params['interval_name'] = req.query.interval_name;
larkin.queryPg("burwell",
sql,
params,
params,
function (error, result) {
console.log("results", result)
if (error) {
callback(error);
} else {
if (result.length === 1) {
callback(null, parseInt(result[0].mid));
if (result.rows.length === 1) {
callback(null, parseInt(result.rows[0].mid));
} else {
larkin.error(req, res, next, "interval not found");
}
Expand All @@ -46,7 +47,7 @@ module.exports = function (req, res, next) {
limit,
[],
function (error, result) {
callback(null, result);
callback(null, result.rows);
},
);
},
Expand Down

0 comments on commit 7b16afc

Please sign in to comment.