From 87fe3dd421b254dfbbcd45b2fccfe9b94a6bf220 Mon Sep 17 00:00:00 2001 From: Patrick Leary Date: Fri, 12 Apr 2024 19:38:48 -0400 Subject: [PATCH] cut back on queries that hit the replica DB --- lib/models/observation_preload.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/models/observation_preload.js b/lib/models/observation_preload.js index bbebf330..23f758aa 100644 --- a/lib/models/observation_preload.js +++ b/lib/models/observation_preload.js @@ -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] = { @@ -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, @@ -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] || []; @@ -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] || [];