Skip to content

Commit

Permalink
cut back on queries that hit the replica DB
Browse files Browse the repository at this point in the history
  • Loading branch information
pleary committed Apr 12, 2024
1 parent 76412ae commit 87fe3dd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/models/observation_preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const ObservationPreload = class ObservationPreload {
.field( "observation_photos.uuid" )
.from( "observation_photos" )
.where( "observation_id IN ?", obsIDs );
const { rows } = await pgClient.replica.query( query.toString( ) );
const { rows } = await pgClient.query( query.toString( ) );
const observationPhotos = { };
_.each( rows, r => {
observationPhotos[r.id] = {
Expand Down Expand Up @@ -196,7 +196,7 @@ const ObservationPreload = class ObservationPreload {
.left_join( "file_prefixes", null, "photos.file_prefix_id = file_prefixes.id" )
.left_join( "file_extensions", null, "photos.file_extension_id = file_extensions.id" )
.where( "photos.id IN ?", photoIDs );
const { rows } = await pgClient.replica.query( query.toString( ) );
const { rows } = await pgClient.query( query.toString( ) );
_.each( rows, r => {
const photo = {
id: r.id,
Expand Down Expand Up @@ -414,7 +414,7 @@ const ObservationPreload = class ObservationPreload {
.left_join( "preferences", null, "project_observations.id = preferences.owner_id "
+ "AND preferences.owner_type='ProjectObservation' AND preferences.name='curator_coordinate_access'" )
.where( "observation_id IN ?", obsIDs );
const result = await pgClient.replica.query( query.toString( ) );
const result = await pgClient.query( query.toString( ) );
const projectObs = { };
_.each( result.rows, r => {
projectObs[r.observation_id] = projectObs[r.observation_id] || [];
Expand Down Expand Up @@ -442,7 +442,7 @@ const ObservationPreload = class ObservationPreload {
const query = squel.select( ).fields( ["id", "observation_id"] )
.from( "identifications" )
.where( "observation_id IN ?", obsIDs );
const { rows } = await pgClient.replica.query( query.toString( ) );
const { rows } = await pgClient.query( query.toString( ) );
const obsIdentifications = { };
_.each( rows, r => {
obsIdentifications[r.observation_id] = obsIdentifications[r.observation_id] || [];
Expand Down

0 comments on commit 87fe3dd

Please sign in to comment.