From 3edfb9bf785ba0abbdb463a95231c9096c6f6615 Mon Sep 17 00:00:00 2001 From: Ken-ichi Ueda Date: Thu, 2 Nov 2023 10:54:59 -0400 Subject: [PATCH 1/2] Added instructions about new required NODE_ENV var --- README.md | 5 +++-- config_example.js | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 628938df..59dddd10 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,9 @@ Our API is documented using the [Swagger](http://swagger.io/)/[OpenAPI](https:// npm install # Fill in vals to connect to Rails, Postgres, and elasticsearch cp config_example.js config.js -# Run the node app on port 4000 -node app.js +# Run the node app on port 4000. NODE_ENV is required, so you'll need to set +# it here or elsewhere in your environment +NODE_ENV=development node app.js ``` # Running Tests diff --git a/config_example.js b/config_example.js index caa620b6..7da64c1d 100644 --- a/config_example.js +++ b/config_example.js @@ -18,6 +18,9 @@ module.exports = { host: INAT_ES_HOST ? `http://${INAT_ES_HOST}:9200` : "http://localhost:9200", geoPointField: "location" }, + // Note that the database name will be inferred from the NODE_ENV + // environment variable, e.g. `inaturalist_${process.env.NODE_ENV}`, or it + // be set explicitly with process.env.INAT_DB_NAME database: { user: INAT_DB_USER || "inaturalist", host: INAT_DB_HOST || "127.0.0.1", From 88677e0dbb508be5f20fc14b139d543ad8fa586f Mon Sep 17 00:00:00 2001 From: Ken-ichi Ueda Date: Thu, 2 Nov 2023 10:58:03 -0400 Subject: [PATCH 2/2] Inlucde iconic_taxon_name in observations.taxonomy response --- lib/models/taxon.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/models/taxon.js b/lib/models/taxon.js index c0a3bb12..dd19642d 100644 --- a/lib/models/taxon.js +++ b/lib/models/taxon.js @@ -540,9 +540,10 @@ const Taxon = class Taxon extends Model { const taxonIDs = _.map( taxa, "id" ); if ( _.isEmpty( taxonIDs ) ) { return; } const query = squel.select( ) - .field( "id, name, rank, rank_level, ancestry, is_active" ) + .field( "taxa.id, taxa.name, taxa.rank, taxa.rank_level, taxa.ancestry, taxa.is_active, iconic_taxa.name AS iconic_taxon_name" ) .from( "taxa" ) - .where( "id IN ?", util.paramArray( taxonIDs ) ); + .join( "taxa iconic_taxa", null, "taxa.iconic_taxon_id = iconic_taxa.id" ) + .where( "taxa.id IN ?", util.paramArray( taxonIDs ) ); const result = await pgClient.query( query.toString( ) ); const taxonDetails = { }; _.each( result.rows, row => {