@dhyasama/totem-models 1.23.0 → 1.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -776,6 +776,9 @@ module.exports = function(mongoose, config) {
776
776
 
777
777
  var self = this;
778
778
 
779
+ var lpPopulateOptions = { path: 'lps' };
780
+ if (config.CUSTOMER_ID != 'GLOBAL_PROCESS') lpPopulateOptions.match = { customer: config.CUSTOMER_ID };
781
+
779
782
  self
780
783
  .findById(id)
781
784
  .populate('people.person', 'name avatarUrl title calendarEventSummaries sources')
@@ -785,10 +788,7 @@ module.exports = function(mongoose, config) {
785
788
  .populate('funds', 'name hexColorCode closeDate')
786
789
  .populate('operating.acquired.public.by', 'name logoUrl')
787
790
  .populate('operating.acquired.private.by', 'name logoUrl')
788
- .populate({
789
- path: 'lps',
790
- match: { customer: config.CUSTOMER_ID }
791
- })
791
+ .populate(lpPopulateOptions)
792
792
  .deepPopulate([
793
793
  'people.person.sources.person',
794
794
  'people.person.calendarEventSummaries.attendees.internal',
package/lib/Person.js CHANGED
@@ -1196,6 +1196,16 @@ module.exports = function(mongoose, config) {
1196
1196
 
1197
1197
  });
1198
1198
 
1199
+ // must have person and customer refs
1200
+ self.sources = _.reject(self.sources, function(source) {
1201
+ return !source.person || !source.customer;
1202
+ });
1203
+
1204
+ // dedupe
1205
+ self.sources = _.uniq(self.sources, function(source) {
1206
+ return source.person.toString() && source.customer.toString();
1207
+ });
1208
+
1199
1209
  next();
1200
1210
 
1201
1211
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "1.23.0",
3
+ "version": "1.23.2",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",