Skip to content

Commit

Permalink
need to figure out a way to bring over the pbdb tables that are used …
Browse files Browse the repository at this point in the history
…in the api
  • Loading branch information
amyfromandi committed Oct 28, 2024
1 parent 1dfe2a3 commit 99c9b8f
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 22 deletions.
13 changes: 5 additions & 8 deletions api-tests/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ import * as path from 'path';


const testFiles = [
'defs_sources.ts'
/*'defs_strat_name_concepts.ts',
'defs_strat_names.ts',
'defs_structures.ts',
'defs_timescales.ts',
'fossils.ts',
//'defs_sources.ts'
//'defs_structures.ts'
//'fossils.ts',
'geologic_units_burwell.ts',
'geologic_units_gmna.ts',
'geologic_units_gmus.ts',
'index.ts',
'geologic_units_gmus.ts'
/*'index.ts',
'mancos_test_cases.ts',
'mobile_fossil_collections.ts',
'mobile_macro_summary.ts',
Expand Down
3 changes: 1 addition & 2 deletions api-tests/v2Tests/defs_strat_name_concepts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
done();
});
});
/*

it("should output CSV", function (done) {
request(settings.host)
.get("/defs/strat_name_concepts?all&format=csv")
Expand All @@ -49,4 +49,3 @@
done();
});
});
*/
5 changes: 3 additions & 2 deletions api-tests/v2Tests/defs_strat_names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@
done();
});
});
/*

it("should return all strat names", function (done) {
this.timeout(5000)
request(settings.host)
.get("/defs/strat_names?all")
.expect(validators.aSuccessfulRequest)
Expand All @@ -92,7 +93,7 @@
done();
});
});
*/

it("should output CSV", function (done) {
request(settings.host)
.get("/defs/strat_names?strat_name=Abercrombie&format=csv")
Expand Down
3 changes: 1 addition & 2 deletions api-tests/v2Tests/defs_structures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
done();
});
});
/*

it("should return CSV", function (done) {
request(settings.host)
.get("/defs/structures?structure_type=fabric&format=csv")
Expand All @@ -104,4 +104,3 @@
done();
});
});
*/
3 changes: 1 addition & 2 deletions api-tests/v2Tests/fossils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
done();
});
});
/*

it("should return a sample", function (done) {
request(settings.host)
.get("/fossils?sample")
Expand Down Expand Up @@ -119,4 +119,3 @@
done();
});
});
*/
4 changes: 2 additions & 2 deletions api-tests/v2Tests/geologic_units_burwell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
done();
});
});
/*

it("should return a sample", function (done) {
request(settings.host)
.get("/geologic_units/burwell?sample")
Expand Down Expand Up @@ -107,4 +107,4 @@
done();
});
});
*/

4 changes: 2 additions & 2 deletions api-tests/v2Tests/geologic_units_gmna.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
done();
});
});
/*

it("should return a sample", function (done) {
request(settings.host)
.get("/geologic_units/gmna?sample")
Expand Down Expand Up @@ -90,4 +90,4 @@
});
});

*/

4 changes: 2 additions & 2 deletions api-tests/v2Tests/geologic_units_gmus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
done();
});
});
/*

it("should return a sample", function (done) {
request(settings.host)
.get("/geologic_units/gmus?sample")
Expand Down Expand Up @@ -182,4 +182,4 @@
});
});

*/

2 changes: 2 additions & 0 deletions v2/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if (process.env.MACROSTRAT_DATABASE != null) {
// Connect using a database URL
const macrostratDatabaseURL = process.env.MACROSTRAT_DATABASE
const elevationDatabaseURL = process.env.ELEVATION_DATABASE ?? macrostratDatabaseURL.replace("5432/macrostrat", "5432/elevation");
//add alice db connection
exports.pg = {
macrostratDatabaseURL,
elevationDatabaseURL
Expand All @@ -29,6 +30,7 @@ exports.postgresDatabases = {
burwell: "macrostrat",
geomacro: "geomacro",
elevation: "elevation",
alice: "alice"
};

// This is the default Redis port
Expand Down
5 changes: 5 additions & 0 deletions v2/fossils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ module.exports = function (req, res, next) {
//TODO there is no pbdb table, so I removed LEFT JOIN pbdb.occ_matrix ON pbdb.coll_matrix.collection_no = pbdb.occ_matrix.collection_no
//I also removed LEFT JOIN pbdb.taxon_lower ON pbdb.occ_matrix.orig_no = pbdb.taxon_lower.orig_no
//removed JOIN pbdb.coll_matrix ON pbdb_matches.collection_no = pbdb.coll_matrix.collection_no

//need dump and restore of pbdb or a copy of only the tables needed for the api to function in postgresql
//find number of routes affected
//find mariadb endpoint notes
//"genus_no": [], "taxon_no": "" are always null
larkin.queryPg("burwell",
"SELECT pbdb_matches.collection_no AS cltn_id, collection_name AS cltn_name, lookup_unit_intervals.t_age, lookup_unit_intervals.b_age, n_occs AS pbdb_occs, COALESCE(GROUP_CONCAT(distinct pbdb.taxon_lower.genus_no), '') AS genus_no, COALESCE(GROUP_CONCAT(distinct pbdb.occ_matrix.taxon_no), '') AS taxon_no, \
pbdb_matches.unit_id, cols.id as col_id, CONCAT(pbdb_matches.ref_id, '|') AS refs " +
Expand Down
2 changes: 2 additions & 0 deletions v2/larkin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ const { Client, Pool } = require("pg");
connectionString = postgresCfg.elevationDatabaseURL
}
connectionDetails = { connectionString }
//add alice db connection

} else {
connectionDetails = { ...credentials.pg }
if (dbName == "elevation") {
/* Special case for elevation database (temporary) */
connectionDetails.database = 'elevation'
}
//add alice db connection
}

const pool = new Pool(connectionDetails);
Expand Down

0 comments on commit 99c9b8f

Please sign in to comment.