From 444364f8415697cd4d75a6863ecd9a3d01b24778 Mon Sep 17 00:00:00 2001 From: Ken-ichi Date: Fri, 3 Nov 2023 15:19:47 -0400 Subject: [PATCH] Add iconic_taxon_name to observations.taxonomy response (#414) Include 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 => {