@dhyasama/totem-models 5.10.5 → 5.10.7

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.
package/lib/Deal.js CHANGED
@@ -60,7 +60,9 @@ module.exports = function(mongoose, config) {
60
60
  timestamp: { type: Date, required: true, default: Date.now },
61
61
  person: { type: Schema.ObjectId, ref: 'Person', required: true },
62
62
  value: { type: Number }
63
- }]
63
+ }],
64
+
65
+ sectors: [{ type: String, trim: true }]
64
66
 
65
67
  });
66
68
 
@@ -95,6 +97,21 @@ module.exports = function(mongoose, config) {
95
97
 
96
98
  });
97
99
 
100
+ Deal.virtual('voteValue').get(function () {
101
+
102
+ var self = this;
103
+
104
+ if(!self.votes || self.votes.length == 0) return null;
105
+
106
+ var voteValue = 0;
107
+ _.each(self.votes, function(vote) {
108
+ voteValue += vote.value;
109
+ });
110
+
111
+ return voteValue;
112
+
113
+ });
114
+
98
115
  ///////////////////////////////////////////////////////////////////////////////////////
99
116
  // METHODS
100
117
  // Methods operate on a single document that has already been returned
@@ -234,22 +251,6 @@ module.exports = function(mongoose, config) {
234
251
  });
235
252
  };
236
253
 
237
- Deal.statics.addVote = function(dealId, personId, vote, cb) {
238
-
239
- var self = this;
240
-
241
- self.findByIdAndUpdate(dealId, {$push:
242
- {
243
- votes: {
244
- timestamp: new Date(),
245
- person: personId,
246
- value: vote
247
- }
248
- }
249
- }, cb);
250
-
251
- };
252
-
253
254
  Deal.statics.upsert = function upsert(deal, user, cb) {
254
255
 
255
256
  // Deal is dumb and doesn't validate customer stages or duplicate deals. That responsibility is with the org.
@@ -215,6 +215,9 @@ module.exports = function(mongoose, config) {
215
215
  name: { type: String, trim: true },
216
216
  value: { type: Number }
217
217
  }]
218
+ },
219
+ sectors: {
220
+ active: { type: Boolean, default: false }
218
221
  }
219
222
  }
220
223
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "5.10.5",
3
+ "version": "5.10.7",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",