@dhyasama/totem-models 1.27.0 → 1.28.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.
- package/lib/LimitedPartner.js +19 -35
- package/lib/Organization.js +37 -15
- package/package.json +1 -1
package/lib/LimitedPartner.js
CHANGED
|
@@ -19,16 +19,7 @@ module.exports = function(mongoose, config) {
|
|
|
19
19
|
async = require('async'),
|
|
20
20
|
utils = require('@dhyasama/ffvc-utilities');
|
|
21
21
|
|
|
22
|
-
var
|
|
23
|
-
Organization.getById(id, function(err, org) {
|
|
24
|
-
if (err) return cb(err, null);
|
|
25
|
-
else if (!org) return cb(null, null);
|
|
26
|
-
var fundIds = _.map(org.funds, function(fund) {
|
|
27
|
-
return mongoose.Types.ObjectId.isValid(fund) || fund._id;
|
|
28
|
-
});
|
|
29
|
-
return cb(null, fundIds);
|
|
30
|
-
});
|
|
31
|
-
};
|
|
22
|
+
var customerFunds = [];
|
|
32
23
|
|
|
33
24
|
var LimitedPartner = new Schema({
|
|
34
25
|
|
|
@@ -407,11 +398,8 @@ module.exports = function(mongoose, config) {
|
|
|
407
398
|
getLp();
|
|
408
399
|
}
|
|
409
400
|
else {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
query = self.findOne({ '_id': id, 'fundsInvested.fund': { $in : fundIds }}, self.getReadFilterKeys(role));
|
|
413
|
-
getLp();
|
|
414
|
-
});
|
|
401
|
+
query = self.findOne({ '_id': id, 'fundsInvested.fund': { $in : self.customerFunds }}, self.getReadFilterKeys(role));
|
|
402
|
+
getLp();
|
|
415
403
|
}
|
|
416
404
|
|
|
417
405
|
};
|
|
@@ -422,11 +410,13 @@ module.exports = function(mongoose, config) {
|
|
|
422
410
|
var query;
|
|
423
411
|
|
|
424
412
|
var getLps = function(q) {
|
|
413
|
+
console.time('getLps');
|
|
425
414
|
q.populate('fundsInvested.fund')
|
|
426
415
|
q.populate('people', 'name')
|
|
427
416
|
q.exec(function (err, lps) {
|
|
428
417
|
if (err) return cb(err, null);
|
|
429
418
|
lps = _.sortBy(lps, function(lp) { return lp.name ? lp.name.toLowerCase() : ''; });
|
|
419
|
+
console.timeEnd('getLps');
|
|
430
420
|
return cb(null, lps);
|
|
431
421
|
});
|
|
432
422
|
};
|
|
@@ -436,11 +426,8 @@ module.exports = function(mongoose, config) {
|
|
|
436
426
|
getLps(query);
|
|
437
427
|
}
|
|
438
428
|
else {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
query = self.find({'people': personId, 'fundsInvested.fund': { $in : fundIds }}, self.getReadFilterKeys(role));
|
|
442
|
-
getLps(query);
|
|
443
|
-
});
|
|
429
|
+
query = self.find({'people': personId, 'fundsInvested.fund': { $in : self.customerFunds }}, self.getReadFilterKeys(role));
|
|
430
|
+
getLps(query);
|
|
444
431
|
}
|
|
445
432
|
|
|
446
433
|
};
|
|
@@ -515,11 +502,8 @@ module.exports = function(mongoose, config) {
|
|
|
515
502
|
getLps(query);
|
|
516
503
|
}
|
|
517
504
|
else {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
query = self.find({ 'fundsInvested.fund': { $in : fundIds }}, self.getReadFilterKeys(role));
|
|
521
|
-
getLps(query);
|
|
522
|
-
});
|
|
505
|
+
query = self.find({ 'fundsInvested.fund': { $in : self.customerFunds }}, self.getReadFilterKeys(role));
|
|
506
|
+
getLps(query);
|
|
523
507
|
}
|
|
524
508
|
|
|
525
509
|
};
|
|
@@ -541,11 +525,8 @@ module.exports = function(mongoose, config) {
|
|
|
541
525
|
});
|
|
542
526
|
};
|
|
543
527
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
query = self.find({ 'fundsInvested.fund': { $in : fundIds }}, self.getReadFilterKeys(role));
|
|
547
|
-
getLps(query);
|
|
548
|
-
});
|
|
528
|
+
query = self.find({ 'fundsInvested.fund': { $in : fundIds }}, self.getReadFilterKeys(role));
|
|
529
|
+
getLps(query);
|
|
549
530
|
|
|
550
531
|
};
|
|
551
532
|
|
|
@@ -643,15 +624,18 @@ module.exports = function(mongoose, config) {
|
|
|
643
624
|
getLps();
|
|
644
625
|
}
|
|
645
626
|
else {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
query = self.find({ 'name': new RegExp(terms, "i"), 'fundsInvested.fund': { $in : fundIds }}, self.getReadFilterKeys(role));
|
|
649
|
-
getLps();
|
|
650
|
-
});
|
|
627
|
+
query = self.find({ 'name': new RegExp(terms, "i"), 'fundsInvested.fund': { $in : self.customerFunds }}, self.getReadFilterKeys(role));
|
|
628
|
+
getLps();
|
|
651
629
|
}
|
|
652
630
|
|
|
653
631
|
};
|
|
654
632
|
|
|
633
|
+
LimitedPartner.statics.setCustomerFunds = function setCustomerFunds(fundids) {
|
|
634
|
+
var self = this;
|
|
635
|
+
self.customerFunds = fundids;
|
|
636
|
+
return self.customerFunds;
|
|
637
|
+
};
|
|
638
|
+
|
|
655
639
|
LimitedPartner.statics.upsert = function(lp, username, role, cb) {
|
|
656
640
|
|
|
657
641
|
if (!lp) { return cb(new Error('lp is required'), null); }
|
package/lib/Organization.js
CHANGED
|
@@ -804,7 +804,7 @@ module.exports = function(mongoose, config) {
|
|
|
804
804
|
|
|
805
805
|
self
|
|
806
806
|
.findById(id)
|
|
807
|
-
.populate('people.person', 'name avatarUrl title doNotDisplay
|
|
807
|
+
.populate('people.person', 'name avatarUrl title doNotDisplay')
|
|
808
808
|
.populate('related', 'name logoUrl')
|
|
809
809
|
.populate('chairs.first', 'name avatarUrl title')
|
|
810
810
|
.populate('chairs.second', 'name avatarUrl title')
|
|
@@ -812,19 +812,6 @@ module.exports = function(mongoose, config) {
|
|
|
812
812
|
.populate('operating.acquired.public.by', 'name logoUrl')
|
|
813
813
|
.populate('operating.acquired.private.by', 'name logoUrl')
|
|
814
814
|
.populate(lpPopulateOptions)
|
|
815
|
-
.deepPopulate([
|
|
816
|
-
'people.person.sources.person',
|
|
817
|
-
'people.person.calendarEventSummaries.attendees.internal',
|
|
818
|
-
'people.person.calendarEventSummaries.attendees.external',
|
|
819
|
-
'people.person.calendarEventSummaries.notes.createdBy'
|
|
820
|
-
], {
|
|
821
|
-
populate: {
|
|
822
|
-
'people.person.sources.person': { select: 'name avatarUrl title doNotDisplay' },
|
|
823
|
-
'people.person.calendarEventSummaries.attendees.internal': { select: 'name avatarUrl title doNotDisplay' },
|
|
824
|
-
'people.person.calendarEventSummaries.attendees.external': { select: 'name avatarUrl title doNotDisplay' },
|
|
825
|
-
'people.person.calendarEventSummaries.notes.createdBy': { select: 'name avatarUrl title doNotDisplay' }
|
|
826
|
-
}
|
|
827
|
-
})
|
|
828
815
|
.exec(cb);
|
|
829
816
|
|
|
830
817
|
};
|
|
@@ -867,6 +854,40 @@ module.exports = function(mongoose, config) {
|
|
|
867
854
|
|
|
868
855
|
};
|
|
869
856
|
|
|
857
|
+
Organization.statics.getInteractions = function getInteractions(orgid, cb) {
|
|
858
|
+
|
|
859
|
+
var self = this;
|
|
860
|
+
|
|
861
|
+
self
|
|
862
|
+
.findById(orgid)
|
|
863
|
+
.populate('people.person', 'name avatarUrl title doNotDisplay calendarEventSummaries')
|
|
864
|
+
.deepPopulate([
|
|
865
|
+
'people.person.calendarEventSummaries.attendees.internal',
|
|
866
|
+
'people.person.calendarEventSummaries.attendees.external',
|
|
867
|
+
'people.person.calendarEventSummaries.notes.createdBy'
|
|
868
|
+
], {
|
|
869
|
+
populate: {
|
|
870
|
+
'people.person.calendarEventSummaries.attendees.internal': { select: 'name avatarUrl title doNotDisplay' },
|
|
871
|
+
'people.person.calendarEventSummaries.attendees.external': { select: 'name avatarUrl title doNotDisplay' },
|
|
872
|
+
'people.person.calendarEventSummaries.notes.createdBy': { select: 'name avatarUrl title doNotDisplay' }
|
|
873
|
+
}
|
|
874
|
+
})
|
|
875
|
+
.exec(cb);
|
|
876
|
+
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
Organization.statics.getList = function getList(cb) {
|
|
880
|
+
|
|
881
|
+
var self = this;
|
|
882
|
+
|
|
883
|
+
self
|
|
884
|
+
.find()
|
|
885
|
+
.select('name website websiteAliases')
|
|
886
|
+
.lean()
|
|
887
|
+
.exec(cb);
|
|
888
|
+
|
|
889
|
+
};
|
|
890
|
+
|
|
870
891
|
Organization.statics.getLpOrgs = function getLpOrgs(lpids, cb) {
|
|
871
892
|
var self = this;
|
|
872
893
|
self
|
|
@@ -907,7 +928,8 @@ module.exports = function(mongoose, config) {
|
|
|
907
928
|
|
|
908
929
|
self
|
|
909
930
|
.findById(id)
|
|
910
|
-
.
|
|
931
|
+
.select('people')
|
|
932
|
+
.populate('people.person', 'name avatarUrl title doNotDisplay sources')
|
|
911
933
|
.deepPopulate([
|
|
912
934
|
'people.person.sources.person'
|
|
913
935
|
], {
|