From 5833df61440f148cba12a65b7d7899edfaca1c52 Mon Sep 17 00:00:00 2001 From: Javi Date: Sun, 1 Dec 2024 02:36:41 +0100 Subject: [PATCH] #4184inat add updater field in json observation field value response --- lib/models/observation.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/models/observation.js b/lib/models/observation.js index 8c193f5e..4593262d 100644 --- a/lib/models/observation.js +++ b/lib/models/observation.js @@ -192,9 +192,21 @@ const Observation = class Observation extends Model { ); } + static preloadLastUpdaterObservationValue(obs) { + const updaterOptions = { + foreignKey: "updater_id", + attrName: "updater" + }; + return ESModel.fetchBelongsTo( + _.flattenDeep(_.map(obs, "ofvs")), + User, updaterOptions + ); + } + static async preloadAllAssociations( req, obs, localeOpts ) { await Observation.preloadAnnotationControlledTerms( obs ); await Observation.preloadMinimal( req, obs, localeOpts ); + await Observation.preloadLastUpdaterObservationValue( obs ); await Observation.preloadObservationFields( obs ); const withProjects = _.filter( _.flattenDeep( [