@chevre/domain 20.2.0-alpha.21 → 20.2.0-alpha.23
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/example/src/chevre/aggregation/aggregateSystem.ts +25 -17
- package/lib/chevre/repo/aggregation.d.ts +2 -2
- package/lib/chevre/repo/aggregation.js +2 -2
- package/lib/chevre/repo/assetTransaction.d.ts +28 -0
- package/lib/chevre/repo/assetTransaction.js +122 -0
- package/lib/chevre/repo/order.d.ts +0 -9
- package/lib/chevre/repo/order.js +0 -49
- package/lib/chevre/repo/task.d.ts +31 -3
- package/lib/chevre/repo/task.js +141 -27
- package/lib/chevre/repo/transaction.d.ts +6 -0
- package/lib/chevre/repo/transaction.js +39 -9
- package/lib/chevre/service/aggregation/system.d.ts +8 -11
- package/lib/chevre/service/aggregation/system.js +36 -37
- package/lib/chevre/service/task.js +6 -9
- package/package.json +2 -2
|
@@ -13,36 +13,44 @@ async function main() {
|
|
|
13
13
|
|
|
14
14
|
const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
|
|
15
15
|
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
16
|
-
const
|
|
17
|
-
const orderRepo = new chevre.repository.Order(mongoose.connection);
|
|
16
|
+
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
18
17
|
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
18
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
19
19
|
|
|
20
|
-
await
|
|
20
|
+
await aggregationRepo.aggregationModel.deleteMany({
|
|
21
|
+
typeOf: { $in: ['AggregateOrder', 'AggregateReservation'] }
|
|
22
|
+
})
|
|
23
|
+
.exec();
|
|
24
|
+
await chevre.service.aggregation.system.aggregateTask({
|
|
21
25
|
aggregationDays: AGGREGATE_DAYS,
|
|
22
|
-
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
23
|
-
clientIds: AGGREGATE_CLIENT_IDS
|
|
26
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
24
27
|
})({
|
|
25
28
|
agregation: aggregationRepo,
|
|
26
|
-
|
|
29
|
+
task: taskRepo
|
|
27
30
|
});
|
|
28
31
|
|
|
29
|
-
await
|
|
32
|
+
await aggregationRepo.aggregationModel.deleteMany({
|
|
33
|
+
typeOf: { $in: ['AggregateOrder', 'AggregateReservation'] }
|
|
34
|
+
})
|
|
35
|
+
.exec();
|
|
36
|
+
await chevre.service.aggregation.system.aggregateReserveTransaction({
|
|
30
37
|
aggregationDays: AGGREGATE_DAYS,
|
|
31
38
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
32
39
|
})({
|
|
33
40
|
agregation: aggregationRepo,
|
|
34
|
-
|
|
41
|
+
assetTransaction: assetTransactionRepo
|
|
35
42
|
});
|
|
36
43
|
|
|
37
|
-
await chevre.service.aggregation.system.
|
|
44
|
+
await chevre.service.aggregation.system.aggregatePlaceOrder({
|
|
38
45
|
aggregationDays: AGGREGATE_DAYS,
|
|
39
|
-
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
46
|
+
excludedProjectId: EXCLUDED_PROJECT_ID,
|
|
47
|
+
clientIds: AGGREGATE_CLIENT_IDS
|
|
40
48
|
})({
|
|
41
49
|
agregation: aggregationRepo,
|
|
42
|
-
|
|
50
|
+
transaction: transactionRepo
|
|
43
51
|
});
|
|
44
52
|
|
|
45
|
-
await chevre.service.aggregation.system.
|
|
53
|
+
await chevre.service.aggregation.system.aggregateAuthorizeOrderAction({
|
|
46
54
|
aggregationDays: AGGREGATE_DAYS,
|
|
47
55
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
48
56
|
})({
|
|
@@ -50,7 +58,7 @@ async function main() {
|
|
|
50
58
|
action: actionRepo
|
|
51
59
|
});
|
|
52
60
|
|
|
53
|
-
await chevre.service.aggregation.system.
|
|
61
|
+
await chevre.service.aggregation.system.aggregateAuthorizeEventServiceOfferAction({
|
|
54
62
|
aggregationDays: AGGREGATE_DAYS,
|
|
55
63
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
56
64
|
})({
|
|
@@ -58,20 +66,20 @@ async function main() {
|
|
|
58
66
|
action: actionRepo
|
|
59
67
|
});
|
|
60
68
|
|
|
61
|
-
await chevre.service.aggregation.system.
|
|
69
|
+
await chevre.service.aggregation.system.aggregateAuthorizePaymentAction({
|
|
62
70
|
aggregationDays: AGGREGATE_DAYS,
|
|
63
71
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
64
72
|
})({
|
|
65
73
|
agregation: aggregationRepo,
|
|
66
|
-
|
|
74
|
+
action: actionRepo
|
|
67
75
|
});
|
|
68
76
|
|
|
69
|
-
await chevre.service.aggregation.system.
|
|
77
|
+
await chevre.service.aggregation.system.aggregateUseAction({
|
|
70
78
|
aggregationDays: AGGREGATE_DAYS,
|
|
71
79
|
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
72
80
|
})({
|
|
73
81
|
agregation: aggregationRepo,
|
|
74
|
-
|
|
82
|
+
action: actionRepo
|
|
75
83
|
});
|
|
76
84
|
}
|
|
77
85
|
|
|
@@ -5,8 +5,8 @@ export declare enum AggregationType {
|
|
|
5
5
|
AggregateAuthorizeEventServiceOfferAction = "AggregateAuthorizeEventServiceOfferAction",
|
|
6
6
|
AggregateAuthorizeOrderAction = "AggregateAuthorizeOrderAction",
|
|
7
7
|
AggregateAuthorizePaymentAction = "AggregateAuthorizePaymentAction",
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
AggregateReserve = "AggregateReserve",
|
|
9
|
+
AggregateTask = "AggregateTask",
|
|
10
10
|
AggregateUseAction = "AggregateUseAction"
|
|
11
11
|
}
|
|
12
12
|
export interface IAggregationByClient {
|
|
@@ -28,8 +28,8 @@ var AggregationType;
|
|
|
28
28
|
AggregationType["AggregateAuthorizeEventServiceOfferAction"] = "AggregateAuthorizeEventServiceOfferAction";
|
|
29
29
|
AggregationType["AggregateAuthorizeOrderAction"] = "AggregateAuthorizeOrderAction";
|
|
30
30
|
AggregationType["AggregateAuthorizePaymentAction"] = "AggregateAuthorizePaymentAction";
|
|
31
|
-
AggregationType["
|
|
32
|
-
AggregationType["
|
|
31
|
+
AggregationType["AggregateReserve"] = "AggregateReserve";
|
|
32
|
+
AggregationType["AggregateTask"] = "AggregateTask";
|
|
33
33
|
AggregationType["AggregateUseAction"] = "AggregateUseAction";
|
|
34
34
|
})(AggregationType = exports.AggregationType || (exports.AggregationType = {}));
|
|
35
35
|
/**
|
|
@@ -2,6 +2,23 @@ import { Connection } from 'mongoose';
|
|
|
2
2
|
import { modelName } from './mongoose/model/assetTransaction';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
export { modelName };
|
|
5
|
+
interface IAggregationByStatus {
|
|
6
|
+
transactionCount: number;
|
|
7
|
+
avgDuration: number;
|
|
8
|
+
maxDuration: number;
|
|
9
|
+
minDuration: number;
|
|
10
|
+
percentilesDuration: {
|
|
11
|
+
name: string;
|
|
12
|
+
value: number;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
interface IStatus {
|
|
16
|
+
status: factory.transactionStatusType;
|
|
17
|
+
aggregation: IAggregationByStatus;
|
|
18
|
+
}
|
|
19
|
+
export interface IAggregateReserve {
|
|
20
|
+
statuses: IStatus[];
|
|
21
|
+
}
|
|
5
22
|
/**
|
|
6
23
|
* 資産取引リポジトリ
|
|
7
24
|
*/
|
|
@@ -123,4 +140,15 @@ export declare class MongoRepository {
|
|
|
123
140
|
findByIdAndDelete(params: {
|
|
124
141
|
id: string;
|
|
125
142
|
}): Promise<void>;
|
|
143
|
+
aggregateReserve(params: {
|
|
144
|
+
project?: {
|
|
145
|
+
id?: {
|
|
146
|
+
$ne?: string;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
startFrom: Date;
|
|
150
|
+
startThrough: Date;
|
|
151
|
+
typeOf: factory.assetTransactionType;
|
|
152
|
+
}): Promise<IAggregateReserve>;
|
|
153
|
+
private agggregateByStatus;
|
|
126
154
|
}
|
|
@@ -536,5 +536,127 @@ class MongoRepository {
|
|
|
536
536
|
.exec();
|
|
537
537
|
});
|
|
538
538
|
}
|
|
539
|
+
aggregateReserve(params) {
|
|
540
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
541
|
+
const statuses = yield Promise.all([
|
|
542
|
+
factory.transactionStatusType.Confirmed,
|
|
543
|
+
factory.transactionStatusType.Canceled,
|
|
544
|
+
factory.transactionStatusType.Expired
|
|
545
|
+
].map((transactionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
546
|
+
var _a, _b;
|
|
547
|
+
const matchConditions = Object.assign({ startDate: {
|
|
548
|
+
$gte: params.startFrom,
|
|
549
|
+
$lte: params.startThrough
|
|
550
|
+
}, typeOf: { $eq: params.typeOf }, status: { $eq: transactionStatus } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
551
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
552
|
+
: undefined);
|
|
553
|
+
return this.agggregateByStatus({ matchConditions, status: transactionStatus });
|
|
554
|
+
})));
|
|
555
|
+
return { statuses };
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
// tslint:disable-next-line:max-func-body-length
|
|
559
|
+
agggregateByStatus(params) {
|
|
560
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
561
|
+
const matchConditions = params.matchConditions;
|
|
562
|
+
const transactionStatus = params.status;
|
|
563
|
+
const aggregations = yield this.transactionModel.aggregate([
|
|
564
|
+
{
|
|
565
|
+
$match: matchConditions
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
$project: {
|
|
569
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
570
|
+
status: '$status',
|
|
571
|
+
startDate: '$startDate',
|
|
572
|
+
endDate: '$endDate',
|
|
573
|
+
typeOf: '$typeOf'
|
|
574
|
+
}
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
$group: {
|
|
578
|
+
_id: '$typeOf',
|
|
579
|
+
transactionCount: { $sum: 1 },
|
|
580
|
+
maxDuration: { $max: '$duration' },
|
|
581
|
+
minDuration: { $min: '$duration' },
|
|
582
|
+
avgDuration: { $avg: '$duration' }
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
$project: {
|
|
587
|
+
_id: 0,
|
|
588
|
+
transactionCount: '$transactionCount',
|
|
589
|
+
avgDuration: '$avgDuration',
|
|
590
|
+
maxDuration: '$maxDuration',
|
|
591
|
+
minDuration: '$minDuration'
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
])
|
|
595
|
+
.exec();
|
|
596
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
597
|
+
const percents = [50, 95, 99];
|
|
598
|
+
if (aggregations.length === 0) {
|
|
599
|
+
return {
|
|
600
|
+
status: transactionStatus,
|
|
601
|
+
aggregation: {
|
|
602
|
+
transactionCount: 0,
|
|
603
|
+
avgDuration: 0,
|
|
604
|
+
maxDuration: 0,
|
|
605
|
+
minDuration: 0,
|
|
606
|
+
percentilesDuration: percents.map((percent) => {
|
|
607
|
+
return {
|
|
608
|
+
name: String(percent),
|
|
609
|
+
value: 0
|
|
610
|
+
};
|
|
611
|
+
})
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
const ranks4percentile = percents.map((percentile) => {
|
|
616
|
+
return {
|
|
617
|
+
percentile,
|
|
618
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
619
|
+
rank: Math.floor(aggregations[0].transactionCount * percentile / 100)
|
|
620
|
+
};
|
|
621
|
+
});
|
|
622
|
+
const aggregations2 = yield this.transactionModel.aggregate([
|
|
623
|
+
{
|
|
624
|
+
$match: matchConditions
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
$project: {
|
|
628
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
629
|
+
status: '$status',
|
|
630
|
+
startDate: '$startDate',
|
|
631
|
+
endDate: '$endDate',
|
|
632
|
+
typeOf: '$typeOf'
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
{ $sort: { duration: 1 } },
|
|
636
|
+
{
|
|
637
|
+
$group: {
|
|
638
|
+
_id: '$typeOf',
|
|
639
|
+
durations: { $push: '$duration' }
|
|
640
|
+
}
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
$project: {
|
|
644
|
+
_id: 0,
|
|
645
|
+
percentilesDuration: ranks4percentile.map((rank) => {
|
|
646
|
+
return {
|
|
647
|
+
name: String(rank.percentile),
|
|
648
|
+
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
649
|
+
};
|
|
650
|
+
})
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
])
|
|
654
|
+
.exec();
|
|
655
|
+
return {
|
|
656
|
+
status: transactionStatus,
|
|
657
|
+
aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
|
|
658
|
+
};
|
|
659
|
+
});
|
|
660
|
+
}
|
|
539
661
|
}
|
|
540
662
|
exports.MongoRepository = MongoRepository;
|
|
@@ -76,13 +76,4 @@ export declare class MongoRepository {
|
|
|
76
76
|
$in: string[];
|
|
77
77
|
};
|
|
78
78
|
}): Promise<(string)[]>;
|
|
79
|
-
aggregateOrder(params: factory.order.ISearchConditions): Promise<{
|
|
80
|
-
orderCount: number;
|
|
81
|
-
acceptedOfferCount: number;
|
|
82
|
-
avgAcceptedOfferCount: number;
|
|
83
|
-
totalPrice: number;
|
|
84
|
-
maxPrice: number;
|
|
85
|
-
minPrice: number;
|
|
86
|
-
avgPrice: number;
|
|
87
|
-
}>;
|
|
88
79
|
}
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -920,54 +920,5 @@ class MongoRepository {
|
|
|
920
920
|
return [...new Set(reservationNumbers)];
|
|
921
921
|
});
|
|
922
922
|
}
|
|
923
|
-
aggregateOrder(params) {
|
|
924
|
-
var _a, _b;
|
|
925
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
926
|
-
const aggregations = yield this.orderModel.aggregate([
|
|
927
|
-
{
|
|
928
|
-
$match: {
|
|
929
|
-
orderDate: {
|
|
930
|
-
$gte: (_a = params.orderDate) === null || _a === void 0 ? void 0 : _a.$gte,
|
|
931
|
-
$lte: (_b = params.orderDate) === null || _b === void 0 ? void 0 : _b.$lte
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
},
|
|
935
|
-
{
|
|
936
|
-
$group: {
|
|
937
|
-
_id: '$typeOf',
|
|
938
|
-
acceptedOfferCount: {
|
|
939
|
-
$sum: {
|
|
940
|
-
$cond: { if: { $isArray: '$acceptedOffers' }, then: { $size: '$acceptedOffers' }, else: 0 }
|
|
941
|
-
}
|
|
942
|
-
},
|
|
943
|
-
avgAcceptedOfferCount: {
|
|
944
|
-
$avg: {
|
|
945
|
-
$cond: { if: { $isArray: '$acceptedOffers' }, then: { $size: '$acceptedOffers' }, else: 0 }
|
|
946
|
-
}
|
|
947
|
-
},
|
|
948
|
-
orderCount: { $sum: 1 },
|
|
949
|
-
totalPrice: { $sum: '$price' },
|
|
950
|
-
maxPrice: { $max: '$price' },
|
|
951
|
-
minPrice: { $min: '$price' },
|
|
952
|
-
avgPrice: { $avg: '$price' }
|
|
953
|
-
}
|
|
954
|
-
},
|
|
955
|
-
{
|
|
956
|
-
$project: {
|
|
957
|
-
_id: 0,
|
|
958
|
-
acceptedOfferCount: '$acceptedOfferCount',
|
|
959
|
-
avgAcceptedOfferCount: '$avgAcceptedOfferCount',
|
|
960
|
-
orderCount: '$orderCount',
|
|
961
|
-
totalPrice: '$totalPrice',
|
|
962
|
-
maxPrice: '$maxPrice',
|
|
963
|
-
minPrice: '$minPrice',
|
|
964
|
-
avgPrice: '$avgPrice'
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
])
|
|
968
|
-
.exec();
|
|
969
|
-
return aggregations[0];
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
923
|
}
|
|
973
924
|
exports.MongoRepository = MongoRepository;
|
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import { Connection, Model } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
|
+
interface IAggregationByStatus {
|
|
4
|
+
taskCount: number;
|
|
5
|
+
avgLatency: number;
|
|
6
|
+
maxLatency: number;
|
|
7
|
+
minLatency: number;
|
|
8
|
+
percentilesLatency: {
|
|
9
|
+
name: string;
|
|
10
|
+
value: number;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
interface IStatus {
|
|
14
|
+
status: factory.taskStatus;
|
|
15
|
+
aggregation: IAggregationByStatus;
|
|
16
|
+
}
|
|
17
|
+
export interface IAggregateTask {
|
|
18
|
+
statuses: IStatus[];
|
|
19
|
+
}
|
|
3
20
|
/**
|
|
4
21
|
* タスクリポジトリ
|
|
5
22
|
*/
|
|
6
23
|
export declare class MongoRepository {
|
|
7
24
|
readonly taskModel: typeof Model;
|
|
8
25
|
constructor(connection: Connection);
|
|
9
|
-
static CREATE_MONGO_CONDITIONS
|
|
26
|
+
static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): any[];
|
|
10
27
|
save(taskAttributes: factory.task.IAttributes<factory.taskName>): Promise<factory.task.ITask<factory.taskName>>;
|
|
11
28
|
saveMany(taskAttributes: factory.task.IAttributes<factory.taskName>[]): Promise<any[]>;
|
|
12
29
|
executeOneByName<T extends factory.taskName>(params: {
|
|
@@ -29,14 +46,25 @@ export declare class MongoRepository {
|
|
|
29
46
|
name: T;
|
|
30
47
|
id: string;
|
|
31
48
|
}): Promise<factory.task.ITask<T>>;
|
|
32
|
-
count
|
|
49
|
+
count(params: factory.task.ISearchConditions): Promise<number>;
|
|
33
50
|
/**
|
|
34
51
|
* 検索する
|
|
35
52
|
*/
|
|
36
|
-
search
|
|
53
|
+
search(params: factory.task.ISearchConditions, projection?: any): Promise<factory.task.ITask<factory.taskName>[]>;
|
|
37
54
|
deleteByProject(params: {
|
|
38
55
|
project: {
|
|
39
56
|
id: string;
|
|
40
57
|
};
|
|
41
58
|
}): Promise<void>;
|
|
59
|
+
aggregateTask(params: {
|
|
60
|
+
project?: {
|
|
61
|
+
id?: {
|
|
62
|
+
$ne?: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
runsFrom: Date;
|
|
66
|
+
runsThrough: Date;
|
|
67
|
+
}): Promise<IAggregateTask>;
|
|
68
|
+
private agggregateByStatus;
|
|
42
69
|
}
|
|
70
|
+
export {};
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -29,29 +29,24 @@ class MongoRepository {
|
|
|
29
29
|
}
|
|
30
30
|
// tslint:disable-next-line:max-func-body-length
|
|
31
31
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
32
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
33
|
-
const andConditions = [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/* istanbul ignore else */
|
|
38
|
-
if (params.project !== undefined) {
|
|
39
|
-
if (params.project.id !== undefined && params.project.id !== null) {
|
|
40
|
-
if (typeof params.project.id.$eq === 'string') {
|
|
41
|
-
andConditions.push({
|
|
42
|
-
'project.id': {
|
|
43
|
-
$eq: params.project.id.$eq
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
32
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
33
|
+
const andConditions = [];
|
|
34
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
35
|
+
if (typeof projectIdEq === 'string') {
|
|
36
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
48
37
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
38
|
+
if (typeof params.name === 'string') {
|
|
39
|
+
andConditions.push({ name: { $eq: params.name } });
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const nameIn = (_c = params.name) === null || _c === void 0 ? void 0 : _c.$in;
|
|
43
|
+
if (Array.isArray(nameIn)) {
|
|
44
|
+
andConditions.push({ name: { $in: nameIn } });
|
|
45
|
+
}
|
|
46
|
+
const nameNin = (_d = params.name) === null || _d === void 0 ? void 0 : _d.$nin;
|
|
47
|
+
if (Array.isArray(nameNin)) {
|
|
48
|
+
andConditions.push({ name: { $nin: nameNin } });
|
|
49
|
+
}
|
|
55
50
|
}
|
|
56
51
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
57
52
|
/* istanbul ignore else */
|
|
@@ -94,7 +89,7 @@ class MongoRepository {
|
|
|
94
89
|
}
|
|
95
90
|
});
|
|
96
91
|
}
|
|
97
|
-
const dateAbortedGte = (
|
|
92
|
+
const dateAbortedGte = (_e = params.dateAborted) === null || _e === void 0 ? void 0 : _e.$gte;
|
|
98
93
|
if (dateAbortedGte instanceof Date) {
|
|
99
94
|
andConditions.push({
|
|
100
95
|
dateAborted: {
|
|
@@ -103,7 +98,7 @@ class MongoRepository {
|
|
|
103
98
|
}
|
|
104
99
|
});
|
|
105
100
|
}
|
|
106
|
-
const dateAbortedLte = (
|
|
101
|
+
const dateAbortedLte = (_f = params.dateAborted) === null || _f === void 0 ? void 0 : _f.$lte;
|
|
107
102
|
if (dateAbortedLte instanceof Date) {
|
|
108
103
|
andConditions.push({
|
|
109
104
|
dateAborted: {
|
|
@@ -112,7 +107,7 @@ class MongoRepository {
|
|
|
112
107
|
}
|
|
113
108
|
});
|
|
114
109
|
}
|
|
115
|
-
const objectTransactionNumberEq = (
|
|
110
|
+
const objectTransactionNumberEq = (_j = (_h = (_g = params.data) === null || _g === void 0 ? void 0 : _g.object) === null || _h === void 0 ? void 0 : _h.transactionNumber) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
116
111
|
if (typeof objectTransactionNumberEq === 'string') {
|
|
117
112
|
andConditions.push({
|
|
118
113
|
'data.object.transactionNumber': {
|
|
@@ -121,7 +116,7 @@ class MongoRepository {
|
|
|
121
116
|
}
|
|
122
117
|
});
|
|
123
118
|
}
|
|
124
|
-
const objectPurposeIdEq = (
|
|
119
|
+
const objectPurposeIdEq = (_m = (_l = (_k = params.data) === null || _k === void 0 ? void 0 : _k.purpose) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$eq;
|
|
125
120
|
if (typeof objectPurposeIdEq === 'string') {
|
|
126
121
|
andConditions.push({
|
|
127
122
|
'data.purpose.id': {
|
|
@@ -130,7 +125,7 @@ class MongoRepository {
|
|
|
130
125
|
}
|
|
131
126
|
});
|
|
132
127
|
}
|
|
133
|
-
const objectPurposeOrderNumberEq = (
|
|
128
|
+
const objectPurposeOrderNumberEq = (_q = (_p = (_o = params.data) === null || _o === void 0 ? void 0 : _o.purpose) === null || _p === void 0 ? void 0 : _p.orderNumber) === null || _q === void 0 ? void 0 : _q.$eq;
|
|
134
129
|
if (typeof objectPurposeOrderNumberEq === 'string') {
|
|
135
130
|
andConditions.push({
|
|
136
131
|
'data.purpose.orderNumber': {
|
|
@@ -312,5 +307,124 @@ class MongoRepository {
|
|
|
312
307
|
.exec();
|
|
313
308
|
});
|
|
314
309
|
}
|
|
310
|
+
aggregateTask(params) {
|
|
311
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
312
|
+
const statuses = yield Promise.all([
|
|
313
|
+
factory.taskStatus.Executed,
|
|
314
|
+
factory.taskStatus.Aborted
|
|
315
|
+
].map((taskStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
316
|
+
var _a, _b;
|
|
317
|
+
const matchConditions = Object.assign({ runsAt: {
|
|
318
|
+
$gte: params.runsFrom,
|
|
319
|
+
$lte: params.runsThrough
|
|
320
|
+
}, status: { $eq: taskStatus } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
321
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
322
|
+
: undefined);
|
|
323
|
+
return this.agggregateByStatus({ matchConditions, status: taskStatus });
|
|
324
|
+
})));
|
|
325
|
+
return { statuses };
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
// tslint:disable-next-line:max-func-body-length
|
|
329
|
+
agggregateByStatus(params) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
const matchConditions = params.matchConditions;
|
|
332
|
+
const taskStatus = params.status;
|
|
333
|
+
const aggregations = yield this.taskModel.aggregate([
|
|
334
|
+
{
|
|
335
|
+
$match: matchConditions
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
$project: {
|
|
339
|
+
latency: { $subtract: ['$lastTriedAt', '$runsAt'] },
|
|
340
|
+
status: '$status',
|
|
341
|
+
runsAt: '$runsAt',
|
|
342
|
+
lastTriedAt: '$lastTriedAt'
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
$group: {
|
|
347
|
+
_id: '$status',
|
|
348
|
+
taskCount: { $sum: 1 },
|
|
349
|
+
maxLatency: { $max: '$latency' },
|
|
350
|
+
minLatency: { $min: '$latency' },
|
|
351
|
+
avgLatency: { $avg: '$latency' }
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
$project: {
|
|
356
|
+
_id: 0,
|
|
357
|
+
taskCount: '$taskCount',
|
|
358
|
+
avgLatency: '$avgLatency',
|
|
359
|
+
maxLatency: '$maxLatency',
|
|
360
|
+
minLatency: '$minLatency'
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
])
|
|
364
|
+
.exec();
|
|
365
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
366
|
+
const percents = [50, 95, 99];
|
|
367
|
+
if (aggregations.length === 0) {
|
|
368
|
+
return {
|
|
369
|
+
status: taskStatus,
|
|
370
|
+
aggregation: {
|
|
371
|
+
taskCount: 0,
|
|
372
|
+
avgLatency: 0,
|
|
373
|
+
maxLatency: 0,
|
|
374
|
+
minLatency: 0,
|
|
375
|
+
percentilesLatency: percents.map((percent) => {
|
|
376
|
+
return {
|
|
377
|
+
name: String(percent),
|
|
378
|
+
value: 0
|
|
379
|
+
};
|
|
380
|
+
})
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
const ranks4percentile = percents.map((percentile) => {
|
|
385
|
+
return {
|
|
386
|
+
percentile,
|
|
387
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
388
|
+
rank: Math.floor(aggregations[0].taskCount * percentile / 100)
|
|
389
|
+
};
|
|
390
|
+
});
|
|
391
|
+
const aggregations2 = yield this.taskModel.aggregate([
|
|
392
|
+
{
|
|
393
|
+
$match: matchConditions
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
$project: {
|
|
397
|
+
latency: { $subtract: ['$lastTriedAt', '$runsAt'] },
|
|
398
|
+
status: '$status',
|
|
399
|
+
runsAt: '$runsAt',
|
|
400
|
+
lastTriedAt: '$lastTriedAt'
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
{ $sort: { latency: 1 } },
|
|
404
|
+
{
|
|
405
|
+
$group: {
|
|
406
|
+
_id: '$status',
|
|
407
|
+
latencies: { $push: '$latency' }
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
$project: {
|
|
412
|
+
_id: 0,
|
|
413
|
+
percentilesLatency: ranks4percentile.map((rank) => {
|
|
414
|
+
return {
|
|
415
|
+
name: String(rank.percentile),
|
|
416
|
+
value: { $arrayElemAt: ['$latencies', rank.rank] }
|
|
417
|
+
};
|
|
418
|
+
})
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
])
|
|
422
|
+
.exec();
|
|
423
|
+
return {
|
|
424
|
+
status: taskStatus,
|
|
425
|
+
aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
|
|
426
|
+
};
|
|
427
|
+
});
|
|
428
|
+
}
|
|
315
429
|
}
|
|
316
430
|
exports.MongoRepository = MongoRepository;
|
|
@@ -11,6 +11,12 @@ interface IAggregationByStatus {
|
|
|
11
11
|
name: string;
|
|
12
12
|
value: number;
|
|
13
13
|
}[];
|
|
14
|
+
acceptedOfferCount: number;
|
|
15
|
+
avgAcceptedOfferCount: number;
|
|
16
|
+
totalPrice: number;
|
|
17
|
+
maxPrice: number;
|
|
18
|
+
minPrice: number;
|
|
19
|
+
avgPrice: number;
|
|
14
20
|
}
|
|
15
21
|
interface IStatus {
|
|
16
22
|
status: factory.transactionStatusType;
|
|
@@ -603,9 +603,9 @@ class MongoRepository {
|
|
|
603
603
|
aggregatePlaceOrder(params) {
|
|
604
604
|
return __awaiter(this, void 0, void 0, function* () {
|
|
605
605
|
const statuses = yield Promise.all([
|
|
606
|
+
factory.transactionStatusType.Confirmed,
|
|
606
607
|
factory.transactionStatusType.Canceled,
|
|
607
|
-
factory.transactionStatusType.Expired
|
|
608
|
-
factory.transactionStatusType.Confirmed
|
|
608
|
+
factory.transactionStatusType.Expired
|
|
609
609
|
].map((transactionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
610
610
|
var _a, _b;
|
|
611
611
|
const matchConditions = Object.assign(Object.assign({ startDate: {
|
|
@@ -680,7 +680,13 @@ class MongoRepository {
|
|
|
680
680
|
name: String(percent),
|
|
681
681
|
value: 0
|
|
682
682
|
};
|
|
683
|
-
})
|
|
683
|
+
}),
|
|
684
|
+
acceptedOfferCount: 0,
|
|
685
|
+
avgAcceptedOfferCount: 0,
|
|
686
|
+
totalPrice: 0,
|
|
687
|
+
maxPrice: 0,
|
|
688
|
+
minPrice: 0,
|
|
689
|
+
avgPrice: 0
|
|
684
690
|
}
|
|
685
691
|
};
|
|
686
692
|
}
|
|
@@ -701,28 +707,52 @@ class MongoRepository {
|
|
|
701
707
|
status: '$status',
|
|
702
708
|
startDate: '$startDate',
|
|
703
709
|
endDate: '$endDate',
|
|
704
|
-
typeOf: '$typeOf'
|
|
710
|
+
typeOf: '$typeOf',
|
|
711
|
+
// result: '$result',
|
|
712
|
+
acceptedOffers: {
|
|
713
|
+
$cond: {
|
|
714
|
+
if: { $isArray: '$result.order.acceptedOffers' },
|
|
715
|
+
then: '$result.order.acceptedOffers',
|
|
716
|
+
else: []
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
price: {
|
|
720
|
+
$cond: {
|
|
721
|
+
if: { $isNumber: '$result.order.price' },
|
|
722
|
+
then: '$result.order.price',
|
|
723
|
+
else: 0
|
|
724
|
+
}
|
|
725
|
+
}
|
|
705
726
|
}
|
|
706
727
|
},
|
|
707
728
|
{ $sort: { duration: 1 } },
|
|
708
729
|
{
|
|
709
730
|
$group: {
|
|
710
731
|
_id: '$typeOf',
|
|
711
|
-
durations: { $push: '$duration' }
|
|
732
|
+
durations: { $push: '$duration' },
|
|
733
|
+
acceptedOfferCount: { $sum: { $size: '$acceptedOffers' } },
|
|
734
|
+
avgAcceptedOfferCount: { $avg: { $size: '$acceptedOffers' } },
|
|
735
|
+
totalPrice: { $sum: '$price' },
|
|
736
|
+
maxPrice: { $max: '$price' },
|
|
737
|
+
minPrice: { $min: '$price' },
|
|
738
|
+
avgPrice: { $avg: '$price' }
|
|
712
739
|
}
|
|
713
740
|
},
|
|
714
741
|
{
|
|
715
742
|
$project: {
|
|
716
743
|
_id: 0,
|
|
717
|
-
avgSmallDuration: '$avgSmallDuration',
|
|
718
|
-
avgMediumDuration: '$avgMediumDuration',
|
|
719
|
-
avgLargeDuration: '$avgLargeDuration',
|
|
720
744
|
percentilesDuration: ranks4percentile.map((rank) => {
|
|
721
745
|
return {
|
|
722
746
|
name: String(rank.percentile),
|
|
723
747
|
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
724
748
|
};
|
|
725
|
-
})
|
|
749
|
+
}),
|
|
750
|
+
acceptedOfferCount: '$acceptedOfferCount',
|
|
751
|
+
avgAcceptedOfferCount: '$avgAcceptedOfferCount',
|
|
752
|
+
totalPrice: '$totalPrice',
|
|
753
|
+
maxPrice: '$maxPrice',
|
|
754
|
+
minPrice: '$minPrice',
|
|
755
|
+
avgPrice: '$avgPrice'
|
|
726
756
|
}
|
|
727
757
|
}
|
|
728
758
|
])
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
2
2
|
import { MongoRepository as AggregationRepo } from '../../repo/aggregation';
|
|
3
|
-
import { MongoRepository as
|
|
4
|
-
import { MongoRepository as
|
|
3
|
+
import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
|
|
4
|
+
import { MongoRepository as TasKRepo } from '../../repo/task';
|
|
5
5
|
import { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
6
6
|
/**
|
|
7
7
|
* 注文取引集計
|
|
@@ -52,23 +52,20 @@ declare function aggregateUseAction(params: {
|
|
|
52
52
|
action: ActionRepo;
|
|
53
53
|
}) => Promise<void>;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* 予約集計
|
|
56
56
|
*/
|
|
57
|
-
declare function
|
|
57
|
+
declare function aggregateReserveTransaction(params: {
|
|
58
58
|
aggregationDays: number;
|
|
59
59
|
excludedProjectId?: string;
|
|
60
60
|
}): (repos: {
|
|
61
61
|
agregation: AggregationRepo;
|
|
62
|
-
|
|
62
|
+
assetTransaction: AssetTransactionRepo;
|
|
63
63
|
}) => Promise<void>;
|
|
64
|
-
|
|
65
|
-
* 予約集計
|
|
66
|
-
*/
|
|
67
|
-
declare function aggregateReservation(params: {
|
|
64
|
+
declare function aggregateTask(params: {
|
|
68
65
|
aggregationDays: number;
|
|
69
66
|
excludedProjectId?: string;
|
|
70
67
|
}): (repos: {
|
|
71
68
|
agregation: AggregationRepo;
|
|
72
|
-
|
|
69
|
+
task: TasKRepo;
|
|
73
70
|
}) => Promise<void>;
|
|
74
|
-
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction,
|
|
71
|
+
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizeOrderAction, aggregateAuthorizePaymentAction, aggregatePlaceOrder, aggregateReserveTransaction, aggregateTask, aggregateUseAction };
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.aggregateUseAction = exports.
|
|
12
|
+
exports.aggregateUseAction = exports.aggregateTask = exports.aggregateReserveTransaction = exports.aggregatePlaceOrder = exports.aggregateAuthorizePaymentAction = exports.aggregateAuthorizeOrderAction = exports.aggregateAuthorizeEventServiceOfferAction = void 0;
|
|
13
13
|
const createDebug = require("debug");
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
15
|
const factory = require("../../factory");
|
|
@@ -20,7 +20,7 @@ const debug = createDebug('chevre-domain:service:aggregation:system');
|
|
|
20
20
|
*/
|
|
21
21
|
function aggregatePlaceOrder(params) {
|
|
22
22
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
var _a;
|
|
23
|
+
var _a, _b;
|
|
24
24
|
const aggregateDate = new Date();
|
|
25
25
|
const aggregateDuration = moment.duration(1, 'days')
|
|
26
26
|
.toISOString();
|
|
@@ -43,19 +43,21 @@ function aggregatePlaceOrder(params) {
|
|
|
43
43
|
startThrough,
|
|
44
44
|
typeOf: factory.transactionType.PlaceOrder
|
|
45
45
|
});
|
|
46
|
-
debug('aggregatePlaceOrder:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation
|
|
46
|
+
debug('aggregatePlaceOrder:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation, startFrom);
|
|
47
47
|
const aggregateResultsByClientId = [];
|
|
48
48
|
if (Array.isArray(params.clientIds)) {
|
|
49
49
|
for (const clientId of params.clientIds) {
|
|
50
|
+
const aggregateResultByClientId = yield repos.transaction.aggregatePlaceOrder({
|
|
51
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
52
|
+
startFrom,
|
|
53
|
+
startThrough,
|
|
54
|
+
typeOf: factory.transactionType.PlaceOrder,
|
|
55
|
+
clientId
|
|
56
|
+
});
|
|
57
|
+
debug('aggregateResultByClientId', aggregateResultByClientId, (_b = aggregateResultByClientId.statuses[0]) === null || _b === void 0 ? void 0 : _b.aggregation, clientId, startFrom);
|
|
50
58
|
aggregateResultsByClientId.push({
|
|
51
59
|
clientId,
|
|
52
|
-
aggregation:
|
|
53
|
-
project: { id: { $ne: params.excludedProjectId } },
|
|
54
|
-
startFrom,
|
|
55
|
-
startThrough,
|
|
56
|
-
typeOf: factory.transactionType.PlaceOrder,
|
|
57
|
-
clientId
|
|
58
|
-
})
|
|
60
|
+
aggregation: aggregateResultByClientId
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -198,69 +200,66 @@ function aggregateUseAction(params) {
|
|
|
198
200
|
}
|
|
199
201
|
exports.aggregateUseAction = aggregateUseAction;
|
|
200
202
|
/**
|
|
201
|
-
*
|
|
203
|
+
* 予約集計
|
|
202
204
|
*/
|
|
203
|
-
function
|
|
205
|
+
function aggregateReserveTransaction(params) {
|
|
204
206
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
207
|
+
var _a;
|
|
205
208
|
const aggregateDate = new Date();
|
|
206
209
|
const aggregateDuration = moment.duration(1, 'days')
|
|
207
210
|
.toISOString();
|
|
208
211
|
let i = -1;
|
|
209
212
|
while (i < params.aggregationDays) {
|
|
210
213
|
i += 1;
|
|
211
|
-
const
|
|
214
|
+
const startFrom = moment()
|
|
212
215
|
// .tz('Asia/Tokyo')
|
|
213
216
|
.add(-i, 'days')
|
|
214
217
|
.startOf('day')
|
|
215
218
|
.toDate();
|
|
216
|
-
const
|
|
219
|
+
const startThrough = moment()
|
|
217
220
|
// .tz('Asia/Tokyo')
|
|
218
221
|
.add(-i, 'days')
|
|
219
222
|
.endOf('day')
|
|
220
223
|
.toDate();
|
|
221
|
-
const aggregateResult = yield repos.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
const aggregateResult = yield repos.assetTransaction.aggregateReserve({
|
|
225
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
226
|
+
startFrom,
|
|
227
|
+
startThrough,
|
|
228
|
+
typeOf: factory.assetTransactionType.Reserve
|
|
226
229
|
});
|
|
227
|
-
debug('
|
|
228
|
-
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.
|
|
230
|
+
debug('aggregateReserveTransaction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation, startFrom);
|
|
231
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateReserve, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
229
232
|
}
|
|
230
233
|
});
|
|
231
234
|
}
|
|
232
|
-
exports.
|
|
233
|
-
|
|
234
|
-
* 予約集計
|
|
235
|
-
*/
|
|
236
|
-
function aggregateReservation(params) {
|
|
235
|
+
exports.aggregateReserveTransaction = aggregateReserveTransaction;
|
|
236
|
+
function aggregateTask(params) {
|
|
237
237
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
238
|
+
var _a;
|
|
238
239
|
const aggregateDate = new Date();
|
|
239
240
|
const aggregateDuration = moment.duration(1, 'days')
|
|
240
241
|
.toISOString();
|
|
241
242
|
let i = -1;
|
|
242
243
|
while (i < params.aggregationDays) {
|
|
243
244
|
i += 1;
|
|
244
|
-
const
|
|
245
|
+
const runsFrom = moment()
|
|
245
246
|
// .tz('Asia/Tokyo')
|
|
246
247
|
.add(-i, 'days')
|
|
247
248
|
.startOf('day')
|
|
248
249
|
.toDate();
|
|
249
|
-
const
|
|
250
|
+
const runsThrough = moment()
|
|
250
251
|
// .tz('Asia/Tokyo')
|
|
251
252
|
.add(-i, 'days')
|
|
252
253
|
.endOf('day')
|
|
253
254
|
.toDate();
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
bookingFrom,
|
|
259
|
-
bookingThrough
|
|
255
|
+
const aggregateResult = yield repos.task.aggregateTask({
|
|
256
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
257
|
+
runsFrom,
|
|
258
|
+
runsThrough
|
|
260
259
|
});
|
|
261
|
-
|
|
262
|
-
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.
|
|
260
|
+
debug('aggregateTask:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation, runsFrom);
|
|
261
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateTask, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: runsFrom, aggregateDate }, aggregateResult));
|
|
263
262
|
}
|
|
264
263
|
});
|
|
265
264
|
}
|
|
266
|
-
exports.
|
|
265
|
+
exports.aggregateTask = aggregateTask;
|
|
@@ -113,16 +113,13 @@ function abort(params) {
|
|
|
113
113
|
exports.abort = abort;
|
|
114
114
|
function notifyAbortedTasks(params) {
|
|
115
115
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
$gte: params.dateAbortedGte
|
|
120
|
-
}
|
|
121
|
-
});
|
|
116
|
+
const abortedTasks = yield repos.task.search(Object.assign({ statuses: [factory.taskStatus.Aborted], dateAborted: { $gte: params.dateAbortedGte } }, (settings_1.ABORTED_TASKS_WITHOUT_REPORT.length > 0)
|
|
117
|
+
? { name: { $nin: settings_1.ABORTED_TASKS_WITHOUT_REPORT } }
|
|
118
|
+
: undefined));
|
|
122
119
|
// 中止を報告しないタスク以外にフィルター
|
|
123
|
-
abortedTasks = abortedTasks.filter((task) => {
|
|
124
|
-
|
|
125
|
-
});
|
|
120
|
+
// abortedTasks = abortedTasks.filter((task) => {
|
|
121
|
+
// return !ABORTED_TASKS_WITHOUT_REPORT.includes(task.name);
|
|
122
|
+
// });
|
|
126
123
|
if (abortedTasks.length > 0) {
|
|
127
124
|
// 開発者へ報告
|
|
128
125
|
const message = (0, factory_1.tasks2lineNotify)({ tasks: abortedTasks });
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
12
|
+
"@chevre/factory": "4.283.0",
|
|
13
13
|
"@cinerino/sdk": "3.135.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -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.
|
|
123
|
+
"version": "20.2.0-alpha.23"
|
|
124
124
|
}
|