Skip to content

Commit 30292ba

Browse files
committed
Merge branch 'column-queries'
* column-queries: (38 commits) Updated small definition issues Removed unnecessary dependencies Remove multiline dependency Streamlined and simplified API tests Major standardization to handling of columns and units Seemed to really improve query handling Updated columns query Improve SQL query building Updated units query Updated handling of valid params Further broke apart units query Improved querying of column params Started streamlining some unit params Slightly streamline unit management Improved parameter validity handling Streamlined where clause handling for units Added column and unit routes Column routes work with original unit-based filtering Started movement to ESM Improve query construction ...
2 parents 910c99b + fc34bc8 commit 30292ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+4205
-7593
lines changed

.mocharc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://json.schemastore.org/mocharc.json",
3+
"require": "tsx"
4+
}

v2/CHANGELOG.md renamed to CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Macrostrat API v2 Changelog
22

3+
## [2.3.0-beta.1] - 2026-01-24
4+
5+
- Create a "fast path" for column queries that do not require unit-based filtering
6+
- Reduce the number of queries made when fetching columns and units
7+
- Convert lots of callback-based code to async/await for better readability
8+
- Started conversion to ESM modules
9+
- Switch from `ts-node` to `tsx`
10+
11+
## [2.2.0] - 2025-12-18
12+
13+
- Update `project_id` handling to accept composite projects or multiple projects.
14+
- `project_id=all` now returns results from all projects.
15+
- Add `project_name` to column output.
16+
317
## [2.1.7] - 2025-11-19
418

519
- Allow multiple `status_code` values in `/columns` route

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ Additionally, you can set a `TEST_PRODUCTION_API_URL` to run comparisons against
5757
another running instance of the API (e.g., production). This is useful for
5858
ensuring that new versions of the API return the same results as older versions.
5959

60+
**NOTE:** The API must be running for tests to succeed. Currently, cryptic errors
61+
are produced if this is not the case.
62+
6063
## Generating a release
6164

6265
Update the version string in `package.json` and run:
File renamed without changes.

api-tests/app.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

api-tests/v2Tests/columns.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,30 @@ it("should return topojson", async function () {
108108
.expect(validators.topoJSON);
109109
});
110110

111+
it("should return all columns as topojson", async function () {
112+
this.timeout(10000);
113+
const localResponse = await request(settings.host)
114+
.get("/columns?all=true&format=topojson")
115+
.expect(validators.aSuccessfulRequest)
116+
.expect(validators.topoJSON)
117+
.expect(returnsManyColumns);
118+
});
119+
120+
function returnsManyColumns(res: {
121+
body: {
122+
success: {
123+
data: { type: "Topology"; objects: { output: { geometries: any[] } } };
124+
};
125+
};
126+
}) {
127+
if (res.body.success.data.type !== "Topology") {
128+
throw new Error("TopoJSON was not returned");
129+
}
130+
if (res.body.success.data.objects.output.geometries.length < 500) {
131+
throw new Error("Not all columns being returned");
132+
}
133+
}
134+
111135
it("should return csv", async function () {
112136
const localResponse = await request(settings.host)
113137
.get("/columns?age=2&format=csv")

api-tests/v2Tests/index.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

api-tests/v2Tests/main.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import type { Suite } from "mocha";
2+
import { createRequire } from "module";
3+
const require = createRequire(import.meta.url);
4+
5+
require("../settings");
6+
7+
const loadTests = (path: string) => {
8+
return () => {
9+
return require(path);
10+
};
11+
};
12+
13+
describe("api/v2", () => {
14+
describe("root", loadTests("./root"));
15+
describe("columns", loadTests("./columns"));
16+
describe("sections", loadTests("./sections"));
17+
describe("units", loadTests("./units"));
18+
describe("fossils", loadTests("./fossils"));
19+
describe("stats", loadTests("./stats"));
20+
21+
describe("defs", loadTests("./defs"));
22+
describe("defs/lithologies", loadTests("./defs_lithologies"));
23+
describe(
24+
"defs/lithology_attributes",
25+
loadTests("./defs_lithology_attributes"),
26+
);
27+
describe("defs/columns", loadTests("./defs_columns"));
28+
describe("defs/econs", loadTests("./defs_econs"));
29+
describe("defs/environments", loadTests("./defs_environments"));
30+
describe("defs/intervals", loadTests("./defs_intervals"));
31+
describe("defs/measurements", loadTests("./defs_measurements"));
32+
describe("defs/minerals", loadTests("./defs_minerals"));
33+
describe("defs/timescales", loadTests("./defs_timescales"));
34+
describe("defs/plates", loadTests("./defs_plates"));
35+
describe("defs/projects", loadTests("./defs_projects"));
36+
describe("defs/groups", loadTests("./defs_groups"));
37+
describe("defs/strat_names", loadTests("./defs_strat_names"));
38+
describe("defs/strat_name_concepts", loadTests("./defs_strat_name_concepts"));
39+
describe("defs/structures", loadTests("./defs_structures"));
40+
describe("defs/refs", loadTests("./defs_refs"));
41+
describe("defs/sources", loadTests("./defs_sources"));
42+
43+
describe("paleogeography", loadTests("./paleogeography"));
44+
//describe("geologic_units/gmna", loadTests("./geologic_units_gmna"), null, true);
45+
//describe("geologic_units/gmus", loadTests("./geologic_units_gmus"));
46+
describe("geologic_units/burwell", loadTests("./geologic_units_burwell"));
47+
48+
describe("carto/small", loadTests("./carto_small"));
49+
50+
describe("tiles", loadTests("./tiles"));
51+
52+
describe("mobile/point", loadTests("./mobile_point"));
53+
//describe("mobile/point_details", loadTests("./mobile_point_details"));
54+
describe(
55+
"mobile/fossil_collections",
56+
loadTests("./mobile_fossil_collections"),
57+
);
58+
describe("mobile/macro_summary", loadTests("./mobile_macro_summary"));
59+
describe("mobile/map_query", loadTests("./mobile_map_query"));
60+
//describe("Mancos test cases", loadTests("./mancos_test_cases"));
61+
});

api-tests/v2Tests/sections.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var request = require("supertest"),
22
validators = require("../validators"),
33
settings = require("../settings");
44

5-
it("should return metadata", function (done) {
5+
it("sections - should return metadata", function (done) {
66
request(settings.host)
77
.get("/sections")
88
.expect(validators.aSuccessfulRequest)
@@ -14,7 +14,7 @@ it("should return metadata", function (done) {
1414
});
1515
});
1616

17-
it("should return a sample", function (done) {
17+
it("sections - should return a sample", function (done) {
1818
request(settings.host)
1919
.get("/sections?sample")
2020
.expect(validators.aSuccessfulRequest)
@@ -25,7 +25,7 @@ it("should return a sample", function (done) {
2525
});
2626
});
2727

28-
it("should accept a column id", function (done) {
28+
it("sections - should accept a column id", function (done) {
2929
request(settings.host)
3030
.get("/sections?col_id=49")
3131
.expect(validators.aSuccessfulRequest)
@@ -37,7 +37,7 @@ it("should accept a column id", function (done) {
3737
});
3838
});
3939

40-
it("should return csv", function (done) {
40+
it("sections - should return csv", function (done) {
4141
request(settings.host)
4242
.get("/sections?col_id=17&format=csv")
4343
.expect(validators.aSuccessfulRequest)

0 commit comments

Comments
 (0)