Skip to content

Commit

Permalink
add conservation status ID in taxon response inaturalist/inaturalist#…
Browse files Browse the repository at this point in the history
…3994; fix bug with common ancestor in some cv responses
  • Loading branch information
pleary committed Feb 26, 2024
1 parent 32c4c20 commit 41fcf0b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/controllers/v1/computervision_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ const ComputervisionController = class ComputervisionController {
commonAncestor.taxon = new Taxon( taxon );
const localeOpts = util.localeOpts( req );
commonAncestor.taxon.prepareForResponse( localeOpts, { localeOpts } );
await TaxaController.assignPlaces( [commonAncestor.taxon] );
response.common_ancestor = commonAncestor;
return response;
}
Expand Down
1 change: 1 addition & 0 deletions lib/controllers/v1/taxa_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,7 @@ TaxaController.iconic = async req => (

module.exports = {
assignAncestors: TaxaController.assignAncestors,
assignPlaces: TaxaController.assignPlaces,
autocomplete: TaxaController.autocomplete,
replaceInactiveTaxa: TaxaController.replaceInactiveTaxa,
search: TaxaController.search,
Expand Down
1 change: 1 addition & 0 deletions lib/models/taxon.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ const Taxon = class Taxon extends Model {
const ids = _.compact( _.uniq( _.flatMapDeep( taxa, t => [t.ancestor_ids, t.id] ) ) );
if ( _.isEmpty( ids ) ) { return; }
const query = squel.select( )
.field( "cs.id" )
.field( "cs.taxon_id" )
.field( "t.name", "taxon_name" )
.field( "t.rank", "taxon_rank" )
Expand Down
1 change: 1 addition & 0 deletions openapi/schema/response/conservation_status.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const Joi = require( "joi" );
const place = require( "./place" );

module.exports = Joi.object( ).keys( {
id: Joi.number( ).integer( ).required( ),
authority: Joi.string( ),
description: Joi.string( ).valid( null ),
geoprivacy: Joi.string( ).valid( null ),
Expand Down

0 comments on commit 41fcf0b

Please sign in to comment.