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( [