@dhyasama/totem-models 11.14.0 → 11.15.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.
Files changed (2) hide show
  1. package/lib/Investment.js +23 -6
  2. package/package.json +1 -1
package/lib/Investment.js CHANGED
@@ -93,24 +93,41 @@ module.exports = function(mongoose, config) {
93
93
 
94
94
  if (err) return cb(err, null);
95
95
 
96
- var investmentWithOrg = _.map(investments, function(inv) {
96
+ var investmentWithRoundDetails = _.map(investments, function(inv) {
97
+
98
+ var fund = null;
99
+ var organization = null;
100
+ var roundName = null;
97
101
 
98
102
  var round = _.find(rounds, function(r) {
103
+
99
104
  return _.some(r.vehicles, function(v) {
100
- return _.some(v.investments, function(investmentId) {
105
+
106
+ var investmentFound = _.some(v.investments, function(investmentId) {
101
107
  return investmentId.toString() === inv._id.toString();
102
108
  });
109
+
110
+ if (investmentFound) {
111
+ fund = v.fund;
112
+ organization = r.organization;
113
+ roundName = r.roundName;
114
+ }
115
+
116
+ return investmentFound;
117
+
103
118
  });
119
+
104
120
  });
105
121
 
106
122
  return _.extend({}, inv.toObject(), {
107
- organization: round ? round.organization : null,
108
- round: round ? round.roundName : null
123
+ organization: organization,
124
+ round: roundName,
125
+ fund: fund
109
126
  });
110
-
127
+
111
128
  });
112
129
 
113
- cb(null, investmentWithOrg);
130
+ cb(null, investmentWithRoundDetails);
114
131
 
115
132
  });
116
133
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "11.14.0",
3
+ "version": "11.15.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",