@chevre/domain 20.2.0-alpha.23 → 20.2.0-alpha.25

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.
@@ -21,24 +21,22 @@ async function main() {
21
21
  typeOf: { $in: ['AggregateOrder', 'AggregateReservation'] }
22
22
  })
23
23
  .exec();
24
- await chevre.service.aggregation.system.aggregateTask({
24
+ await chevre.service.aggregation.system.aggregateReserveTransaction({
25
25
  aggregationDays: AGGREGATE_DAYS,
26
26
  excludedProjectId: EXCLUDED_PROJECT_ID
27
27
  })({
28
28
  agregation: aggregationRepo,
29
- task: taskRepo
29
+ assetTransaction: assetTransactionRepo
30
30
  });
31
31
 
32
- await aggregationRepo.aggregationModel.deleteMany({
33
- typeOf: { $in: ['AggregateOrder', 'AggregateReservation'] }
34
- })
35
- .exec();
36
- await chevre.service.aggregation.system.aggregateReserveTransaction({
32
+ return;
33
+
34
+ await chevre.service.aggregation.system.aggregateTask({
37
35
  aggregationDays: AGGREGATE_DAYS,
38
36
  excludedProjectId: EXCLUDED_PROJECT_ID
39
37
  })({
40
38
  agregation: aggregationRepo,
41
- assetTransaction: assetTransactionRepo
39
+ task: taskRepo
42
40
  });
43
41
 
44
42
  await chevre.service.aggregation.system.aggregatePlaceOrder({
@@ -11,6 +11,10 @@ interface IAggregationByStatus {
11
11
  name: string;
12
12
  value: number;
13
13
  }[];
14
+ reservationCount: number;
15
+ avgGraceTime: number;
16
+ maxGraceTime: number;
17
+ minGraceTime: number;
14
18
  }
15
19
  interface IStatus {
16
20
  status: factory.transactionStatusType;
@@ -567,10 +567,18 @@ class MongoRepository {
567
567
  {
568
568
  $project: {
569
569
  duration: { $subtract: ['$endDate', '$startDate'] },
570
+ graceTime: { $subtract: ['$object.reservationFor.startDate', '$startDate'] },
570
571
  status: '$status',
571
572
  startDate: '$startDate',
572
573
  endDate: '$endDate',
573
- typeOf: '$typeOf'
574
+ typeOf: '$typeOf',
575
+ reservationCount: {
576
+ $cond: {
577
+ if: { $isArray: '$object.subReservation' },
578
+ then: { $size: '$object.subReservation' },
579
+ else: 0
580
+ }
581
+ }
574
582
  }
575
583
  },
576
584
  {
@@ -579,7 +587,11 @@ class MongoRepository {
579
587
  transactionCount: { $sum: 1 },
580
588
  maxDuration: { $max: '$duration' },
581
589
  minDuration: { $min: '$duration' },
582
- avgDuration: { $avg: '$duration' }
590
+ avgDuration: { $avg: '$duration' },
591
+ reservationCount: { $sum: '$reservationCount' },
592
+ maxGraceTime: { $max: '$graceTime' },
593
+ minGraceTime: { $min: '$graceTime' },
594
+ avgGraceTime: { $avg: '$graceTime' }
583
595
  }
584
596
  },
585
597
  {
@@ -588,7 +600,11 @@ class MongoRepository {
588
600
  transactionCount: '$transactionCount',
589
601
  avgDuration: '$avgDuration',
590
602
  maxDuration: '$maxDuration',
591
- minDuration: '$minDuration'
603
+ minDuration: '$minDuration',
604
+ reservationCount: '$reservationCount',
605
+ avgGraceTime: '$avgGraceTime',
606
+ maxGraceTime: '$maxGraceTime',
607
+ minGraceTime: '$minGraceTime'
592
608
  }
593
609
  }
594
610
  ])
@@ -608,7 +624,11 @@ class MongoRepository {
608
624
  name: String(percent),
609
625
  value: 0
610
626
  };
611
- })
627
+ }),
628
+ reservationCount: 0,
629
+ avgGraceTime: 0,
630
+ maxGraceTime: 0,
631
+ minGraceTime: 0
612
632
  }
613
633
  };
614
634
  }
package/package.json CHANGED
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.2.0-alpha.23"
123
+ "version": "20.2.0-alpha.25"
124
124
  }