@dhyasama/totem-models 11.35.0 → 11.37.0

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.
@@ -446,6 +446,14 @@ module.exports = function(mongoose, config) {
446
446
 
447
447
  });
448
448
 
449
+ if (options.fundids) {
450
+ lp.transactions = _.filter(lp.transactions, function(transaction) {
451
+ return _.find(options.fundids, function(f) {
452
+ return transaction.fund._id.toString() === f.toString();
453
+ });
454
+ });
455
+ }
456
+
449
457
  return cb(null, lp);
450
458
 
451
459
  });
@@ -661,7 +669,23 @@ module.exports = function(mongoose, config) {
661
669
  query.populate('transactions.fund');
662
670
  query.populate('people');
663
671
  query.sort({ 'name': -1 });
664
- query.exec(cb);
672
+ query.exec(function(err, result) {
673
+
674
+ if (err) return cb(err);
675
+
676
+ if (options.fundids) {
677
+ _.each(result, function(lp) {
678
+ lp.transactions = _.filter(lp.transactions, function(transaction) {
679
+ return _.find(options.fundids, function(f) {
680
+ return transaction.fund._id.toString() === f.toString();
681
+ });
682
+ });
683
+ });
684
+ }
685
+
686
+ return cb(null, result);
687
+
688
+ });
665
689
 
666
690
  };
667
691
 
package/lib/Round.js CHANGED
@@ -665,7 +665,7 @@ module.exports = function(mongoose, config) {
665
665
 
666
666
  let query = self.find({ 'vehicles.fund': { $in: fundIds } });
667
667
 
668
- query.select('organization');
668
+ query.select('organization vehicles');
669
669
  query.populate('organization', 'name website status ipo operating people');
670
670
 
671
671
  query.exec(function(err, rounds) {
@@ -685,13 +685,18 @@ module.exports = function(mongoose, config) {
685
685
  const grouped = _.groupBy(rounds, function(r) { return r.organization._id; });
686
686
 
687
687
  _.each(grouped, function(rounds) {
688
+
689
+ var fundList = _.uniq(_.flatten(_.map(rounds, function(round) {
690
+ return round.vehicles ? _.map(round.vehicles, function(vehicle) { return vehicle.fund.toString(); }) : [];
691
+ })));
688
692
 
689
693
  portfolio.push({
690
694
  _id: rounds[0].organization._id,
691
695
  name: rounds[0].organization.name,
692
696
  website: rounds[0].organization.website,
693
697
  status: rounds[0].organization.status,
694
- people: rounds[0].organization.people
698
+ people: rounds[0].organization.people,
699
+ funds: fundList
695
700
  });
696
701
 
697
702
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "11.35.0",
3
+ "version": "11.37.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",