Skip to content

Commit

Permalink
more tuning of replica queries; restore taxon_photos to CV responses
Browse files Browse the repository at this point in the history
  • Loading branch information
pleary committed Apr 19, 2024
1 parent c6b5424 commit 85e22c2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/controllers/v1/computervision_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ const ComputervisionController = class ComputervisionController {
};
const taxonOpts = {
modifier: prepareTaxon,
source: { excludes: ["photos", "taxon_photos", "place_ids"] }
source: { excludes: ["photos", "place_ids"] }
};

// if there were taxa added to the counts to replace inactive taxa,
Expand Down
2 changes: 1 addition & 1 deletion lib/controllers/v1/projects_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ const ProjectsController = class ProjectsController {
)
.where( "p.id IN ?", ids )
.where( "pu.user_id = ?", req.userSession.user_id );
const { rows } = await pgClient.query( query.toString( ) );
const { rows } = await pgClient.replica.query( query.toString( ) );
_.each( rows, row => {
row.prefers_updates = ( row.prefers_updates !== "f" );
} );
Expand Down
2 changes: 1 addition & 1 deletion lib/controllers/v1/taxa_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ TaxaController.mapLayers = async req => {
.join( "place_geometries pg", null, "pg.place_id = lt.place_id" )
.where( "lt.taxon_id = ?", req.params.id )
.limit( 1 );
results = await pgClient.query( query.toString( ) );
results = await pgClient.replica.query( query.toString( ) );
const hasListedPlaces = !_.isEmpty( results.rows );

query = squel.select( ).field( "1" )
Expand Down
6 changes: 3 additions & 3 deletions lib/models/taxon.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ const Taxon = class Taxon extends Model {
const query = squel.select( ).field( "id, name " ).from( "taxa" )
.where( "name IN ?", _.keys( iconicTaxaNames ) )
.order( "observations_count", false );
const { rows } = await pgClient.query( query.toString( ) );
const { rows } = await pgClient.replica.query( query.toString( ) );
_.each( rows, r => {
if ( iconicTaxaByName[r.name.toLowerCase( )] === undefined ) {
iconicTaxaByName[r.name.toLowerCase( )] = r;
Expand Down Expand Up @@ -458,7 +458,7 @@ const Taxon = class Taxon extends Model {
.from( "taxa t" )
.left_join( "taxon_descriptions td", null, "t.id = td.taxon_id" )
.where( "t.id IN ?", ids );
const { rows } = await pgClient.query( query.toString( ) );
const { rows } = await pgClient.replica.query( query.toString( ) );
const byTaxonID = { };
_.each( rows, r => {
byTaxonID[r.id] = byTaxonID[r.id] || [];
Expand Down Expand Up @@ -566,7 +566,7 @@ const Taxon = class Taxon extends Model {
}
const query = squel.select( ).field( "id, ancestry " ).from( "taxa" )
.where( "id IN ?", ids );
const { rows } = await pgClient.query( query.toString( ) );
const { rows } = await pgClient.replica.query( query.toString( ) );
const idsObject = _.keyBy( ids );
const knownAncestors = { };
_.each( rows, r => {
Expand Down

0 comments on commit 85e22c2

Please sign in to comment.