@dhyasama/totem-models 1.17.0 → 1.17.1

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.
@@ -409,12 +409,29 @@ module.exports = function(mongoose, config) {
409
409
  LimitedPartner.statics.getByPersonId = function(personId, role, cb) {
410
410
 
411
411
  var self = this;
412
+ var query;
412
413
 
413
- self
414
- .find({'people': personId}, this.getReadFilterKeys(role))
415
- .populate('fundsInvested.fund')
416
- .populate('people', 'name')
417
- .exec(cb);
414
+ var getLps = function(q) {
415
+ q.populate('fundsInvested.fund')
416
+ q.populate('people', 'name')
417
+ q.exec(function (err, lps) {
418
+ if (err) return cb(err, null);
419
+ lps = _.sortBy(lps, function(lp) { return lp.name ? lp.name.toLowerCase() : ''; });
420
+ return cb(null, lps);
421
+ });
422
+ };
423
+
424
+ if (CUSTOMER_ID == 'GLOBAL_PROCESS') {
425
+ query = self.find({'people': personId}, this.getReadFilterKeys(role))
426
+ getLps(query);
427
+ }
428
+ else {
429
+ getFundIdsForCustomer(function(err, fundIds) {
430
+ if (err) return cb(err, null);
431
+ query = self.find({'people': personId, 'fundsInvested.fund': { $in : fundIds }}, self.getReadFilterKeys(role));
432
+ getLps(query);
433
+ });
434
+ }
418
435
 
419
436
  };
420
437
 
@@ -426,29 +443,25 @@ module.exports = function(mongoose, config) {
426
443
 
427
444
  var self = this;
428
445
  var query;
429
- var getLps = function() {
430
- query.populate('fundsInvested.fund')
431
- query.exec(function (err, lps) {
432
446
 
447
+ var getLps = function(q) {
448
+ q.populate('fundsInvested.fund')
449
+ q.exec(function (err, lps) {
433
450
  if (err) return cb(err, null);
434
-
435
- lps = _.sortBy(lps, function(lp) {
436
- return lp.name ? lp.name.toLowerCase() : '';
437
- });
438
-
451
+ lps = _.sortBy(lps, function(lp) { return lp.name ? lp.name.toLowerCase() : ''; });
439
452
  return cb(null, lps);
440
453
  });
441
454
  };
442
455
 
443
456
  if (CUSTOMER_ID == 'GLOBAL_PROCESS') {
444
457
  query = self.find({}, self.getReadFilterKeys(role));
445
- getLps();
458
+ getLps(query);
446
459
  }
447
460
  else {
448
461
  getFundIdsForCustomer(function(err, fundIds) {
449
462
  if (err) return cb(err, null);
450
463
  query = self.find({ 'fundsInvested.fund': { $in : fundIds }}, self.getReadFilterKeys(role));
451
- getLps();
464
+ getLps(query);
452
465
  });
453
466
  }
454
467
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "1.17.0",
3
+ "version": "1.17.1",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",