@dhyasama/totem-models 1.17.1 → 1.17.2

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/Round.js +104 -80
  2. package/package.json +1 -1
package/lib/Round.js CHANGED
@@ -400,43 +400,49 @@ module.exports = function(mongoose, config) {
400
400
 
401
401
  var self = this;
402
402
 
403
- self
404
- .find({
405
- 'deleted': { $ne: true },
406
- 'organization': orgId
407
- })
408
- .populate('organization', 'name logoUrl')
409
- .populate('people.person', 'name avatarUrl title')
410
- .populate('vehicles.fund', 'name shortName')
411
- .populate({
403
+ var query = self.find({
404
+ 'deleted': { $ne: true },
405
+ 'organization': orgId
406
+ });
407
+ query.populate('organization', 'name logoUrl');
408
+ query.populate('people.person', 'name avatarUrl title');
409
+ query.populate('vehicles.fund', 'name shortName');
410
+
411
+ if (config.CUSTOMER_ID == 'GLOBAL_PROCESS') {
412
+ query.populate('vehicles.investments');
413
+ }
414
+ else {
415
+ query.populate({
412
416
  path: 'vehicles.investments',
413
417
  match: { customer: config.CUSTOMER_ID }
414
- })
415
- .exec(function(err, rounds) {
418
+ });
419
+ }
416
420
 
417
- if (err) return cb(err, null);
418
- if (!rounds || rounds.length == 0) return cb(null, []);
421
+ query.exec(function(err, rounds) {
419
422
 
420
- var error = checkForUnpopulatedData(rounds, 'Round.getByOrg');
421
- if (error) return cb(error, null);
423
+ if (err) return cb(err, null);
424
+ if (!rounds || rounds.length == 0) return cb(null, []);
422
425
 
423
- // reverse chronological
424
- rounds = _.sortBy(rounds, function(r) {
426
+ var error = checkForUnpopulatedData(rounds, 'Round.getByOrg');
427
+ if (error) return cb(error, null);
425
428
 
426
- var date = r.closingDate;
429
+ // reverse chronological
430
+ rounds = _.sortBy(rounds, function(r) {
427
431
 
428
- // use investment date in absence of closing date
429
- if (!date && r.vehicles.length && r.vehicles[0].investments.length) {
430
- date = r.vehicles[0].investments[0].investmentDate;
431
- }
432
+ var date = r.closingDate;
432
433
 
433
- return date;
434
+ // use investment date in absence of closing date
435
+ if (!date && r.vehicles.length && r.vehicles[0].investments.length) {
436
+ date = r.vehicles[0].investments[0].investmentDate;
437
+ }
434
438
 
435
- }).reverse();
439
+ return date;
436
440
 
437
- return cb(null, rounds);
441
+ }).reverse();
438
442
 
439
- });
443
+ return cb(null, rounds);
444
+
445
+ });
440
446
 
441
447
  };
442
448
 
@@ -444,43 +450,49 @@ module.exports = function(mongoose, config) {
444
450
 
445
451
  var self = this;
446
452
 
447
- self
448
- .find({
449
- 'deleted': { $ne: true },
450
- 'organization': { $in: orgIds }
451
- })
452
- .populate('organization', 'name logoUrl')
453
- .populate('people.person', 'name avatarUrl')
454
- .populate('vehicles.fund')
455
- .populate({
453
+ var query = self.find({
454
+ 'deleted': { $ne: true },
455
+ 'organization': { $in: orgIds }
456
+ });
457
+ query.populate('organization', 'name logoUrl');
458
+ query.populate('people.person', 'name avatarUrl');
459
+ query.populate('vehicles.fund');
460
+
461
+ if (config.CUSTOMER_ID == 'GLOBAL_PROCESS') {
462
+ query.populate('vehicles.investments');
463
+ }
464
+ else {
465
+ query.populate({
456
466
  path: 'vehicles.investments',
457
467
  match: { customer: config.CUSTOMER_ID }
458
- })
459
- .exec(function(err, rounds) {
468
+ });
469
+ }
460
470
 
461
- if (err) return cb(err, null);
462
- if (!rounds || rounds.length == 0) return cb(null, []);
471
+ query.exec(function(err, rounds) {
463
472
 
464
- var error = checkForUnpopulatedData(rounds, 'Round.getByOrgs');
465
- if (error) return cb(error, null);
473
+ if (err) return cb(err, null);
474
+ if (!rounds || rounds.length == 0) return cb(null, []);
466
475
 
467
- // reverse chronological
468
- rounds = _.sortBy(rounds, function(r) {
476
+ var error = checkForUnpopulatedData(rounds, 'Round.getByOrgs');
477
+ if (error) return cb(error, null);
469
478
 
470
- var date = r.closingDate;
479
+ // reverse chronological
480
+ rounds = _.sortBy(rounds, function(r) {
471
481
 
472
- // use investment date in absence of closing date
473
- if (!date && r.vehicles.length && r.vehicles[0].investments.length) {
474
- date = r.vehicles[0].investments[0].investmentDate;
475
- }
482
+ var date = r.closingDate;
476
483
 
477
- return date;
484
+ // use investment date in absence of closing date
485
+ if (!date && r.vehicles.length && r.vehicles[0].investments.length) {
486
+ date = r.vehicles[0].investments[0].investmentDate;
487
+ }
478
488
 
479
- }).reverse();
489
+ return date;
480
490
 
481
- return cb(null, rounds);
491
+ }).reverse();
482
492
 
483
- });
493
+ return cb(null, rounds);
494
+
495
+ });
484
496
 
485
497
  };
486
498
 
@@ -530,26 +542,32 @@ module.exports = function(mongoose, config) {
530
542
 
531
543
  var self = this;
532
544
 
533
- self
534
- .find({ 'vehicles.fund': fundId })
535
- .select('organization vehicles preMoneyValuation')
536
- .populate('organization', 'name logoUrl description contact industries status ipo closed acquired operating')
537
- .populate('vehicles.fund')
538
- .populate({
545
+ var query = self.find({ 'vehicles.fund': fundId });
546
+ query.select('organization vehicles preMoneyValuation');
547
+ query.populate('organization', 'name logoUrl description contact industries status ipo closed acquired operating');
548
+ query.populate('vehicles.fund');
549
+
550
+ if (config.CUSTOMER_ID == 'GLOBAL_PROCESS') {
551
+ query.populate('vehicles.investments');
552
+ }
553
+ else {
554
+ query.populate({
539
555
  path: 'vehicles.investments',
540
556
  match: { customer: config.CUSTOMER_ID }
541
- })
542
- .exec(function(err, rounds) {
557
+ });
558
+ }
543
559
 
544
- if (err) return cb(err, null);
545
- if (!rounds || rounds.length == 0) return cb(null, []);
560
+ query.exec(function(err, rounds) {
546
561
 
547
- var error = checkForUnpopulatedData(rounds, 'Round.getPortfolioByFund');
548
- if (error) return cb(error, null);
562
+ if (err) return cb(err, null);
563
+ if (!rounds || rounds.length == 0) return cb(null, []);
549
564
 
550
- return cb(null, buildPortfolio(rounds, [fundId]));
565
+ var error = checkForUnpopulatedData(rounds, 'Round.getPortfolioByFund');
566
+ if (error) return cb(error, null);
551
567
 
552
- });
568
+ return cb(null, buildPortfolio(rounds, [fundId]));
569
+
570
+ });
553
571
 
554
572
  };
555
573
 
@@ -560,26 +578,32 @@ module.exports = function(mongoose, config) {
560
578
 
561
579
  var self = this;
562
580
 
563
- self
564
- .find({ 'vehicles.fund': { $in: fundIds } })
565
- .select('organization vehicles preMoneyValuation')
566
- .populate('organization', 'name logoUrl description contact industries status ipo closed acquired operating')
567
- .populate('vehicles.fund')
568
- .populate({
581
+ var query = self.find({ 'vehicles.fund': { $in: fundIds } });
582
+ query.select('organization vehicles preMoneyValuation');
583
+ query.populate('organization', 'name logoUrl description contact industries status ipo closed acquired operating');
584
+ query.populate('vehicles.fund');
585
+
586
+ if (config.CUSTOMER_ID == 'GLOBAL_PROCESS') {
587
+ query.populate('vehicles.investments');
588
+ }
589
+ else {
590
+ query.populate({
569
591
  path: 'vehicles.investments',
570
592
  match: { customer: config.CUSTOMER_ID }
571
- })
572
- .exec(function(err, rounds) {
593
+ });
594
+ }
573
595
 
574
- if (err) return cb(err, null);
575
- if (!rounds || rounds.length == 0) return cb(null, []);
596
+ query.exec(function(err, rounds) {
576
597
 
577
- var error = checkForUnpopulatedData(rounds, 'Round.getPortfolioByFunds');
578
- if (error) return cb(error, null);
598
+ if (err) return cb(err, null);
599
+ if (!rounds || rounds.length == 0) return cb(null, []);
579
600
 
580
- return cb(null, buildPortfolio(rounds, fundIds));
601
+ var error = checkForUnpopulatedData(rounds, 'Round.getPortfolioByFunds');
602
+ if (error) return cb(error, null);
581
603
 
582
- });
604
+ return cb(null, buildPortfolio(rounds, fundIds));
605
+
606
+ });
583
607
 
584
608
  };
585
609
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "1.17.1",
3
+ "version": "1.17.2",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",