@chevre/domain 20.2.0-alpha.18 → 20.2.0-alpha.19
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 +72 -0
- package/lib/chevre/repo/action.d.ts +10 -0
- package/lib/chevre/repo/action.js +21 -2
- package/lib/chevre/repo/aggregation.d.ts +20 -0
- package/lib/chevre/repo/aggregation.js +51 -1
- package/lib/chevre/repo/order.d.ts +1 -1
- package/lib/chevre/repo/order.js +14 -1
- package/lib/chevre/repo/transaction.d.ts +11 -1
- package/lib/chevre/repo/transaction.js +108 -119
- package/lib/chevre/service/aggregation/system.d.ts +66 -0
- package/lib/chevre/service/aggregation/system.js +220 -0
- package/lib/chevre/service/aggregation.d.ts +2 -0
- package/lib/chevre/service/aggregation.js +3 -1
- package/package.json +1 -1
- package/example/src/chevre/aggregation/aggregateAuthorizeActionsGlobally.ts +0 -87
- package/example/src/chevre/aggregation/aggregateAuthorizePaymentActionsGlobally.ts +0 -87
- package/example/src/chevre/aggregation/aggregateOrdersGlobally.ts +0 -113
- package/example/src/chevre/aggregation/aggregateReservationsGlobally.ts +0 -84
- package/example/src/chevre/aggregation/aggregateTransactionsGlobally.ts +0 -104
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: <string>process.env.PROJECT_ID };
|
|
7
|
+
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
8
|
+
const AGGREGATE_DAYS = Number(process.env.AGGREGATE_DAYS);
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
|
|
14
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
15
|
+
const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
|
|
16
|
+
const orderRepo = new chevre.repository.Order(mongoose.connection);
|
|
17
|
+
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
18
|
+
|
|
19
|
+
await chevre.service.aggregation.system.aggregatePlaceOrder({
|
|
20
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
21
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
22
|
+
})({
|
|
23
|
+
agregation: aggregationRepo,
|
|
24
|
+
transaction: transactionRepo
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
await chevre.service.aggregation.system.aggregateAuthorizeEventServiceOfferAction({
|
|
28
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
29
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
30
|
+
})({
|
|
31
|
+
agregation: aggregationRepo,
|
|
32
|
+
action: actionRepo
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
await chevre.service.aggregation.system.aggregateAuthorizePaymentAction({
|
|
36
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
37
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
38
|
+
})({
|
|
39
|
+
agregation: aggregationRepo,
|
|
40
|
+
action: actionRepo
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
await chevre.service.aggregation.system.aggregateUseAction({
|
|
44
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
45
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
46
|
+
})({
|
|
47
|
+
agregation: aggregationRepo,
|
|
48
|
+
action: actionRepo
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
await chevre.service.aggregation.system.aggregateOrder({
|
|
52
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
53
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
54
|
+
})({
|
|
55
|
+
agregation: aggregationRepo,
|
|
56
|
+
order: orderRepo
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
await chevre.service.aggregation.system.aggregateReservation({
|
|
60
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
61
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
62
|
+
})({
|
|
63
|
+
agregation: aggregationRepo,
|
|
64
|
+
reservation: reservationRepo
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
main()
|
|
69
|
+
.then(() => {
|
|
70
|
+
console.log('success!');
|
|
71
|
+
})
|
|
72
|
+
.catch(console.error);
|
|
@@ -144,5 +144,15 @@ export declare class MongoRepository {
|
|
|
144
144
|
startThrough: Date;
|
|
145
145
|
typeOf: factory.actionType;
|
|
146
146
|
}): Promise<IAggregateAction>;
|
|
147
|
+
aggregateUseAction(params: {
|
|
148
|
+
project?: {
|
|
149
|
+
id?: {
|
|
150
|
+
$ne?: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
startFrom: Date;
|
|
154
|
+
startThrough: Date;
|
|
155
|
+
typeOf: factory.actionType;
|
|
156
|
+
}): Promise<IAggregateAction>;
|
|
147
157
|
private agggregateByStatus;
|
|
148
158
|
}
|
|
@@ -680,8 +680,8 @@ class MongoRepository {
|
|
|
680
680
|
aggregateAuthorizeEventServiceOfferAction(params) {
|
|
681
681
|
return __awaiter(this, void 0, void 0, function* () {
|
|
682
682
|
const statuses = yield Promise.all([
|
|
683
|
-
factory.actionStatusType.CanceledActionStatus,
|
|
684
683
|
factory.actionStatusType.CompletedActionStatus,
|
|
684
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
685
685
|
factory.actionStatusType.FailedActionStatus
|
|
686
686
|
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
687
687
|
var _a, _b;
|
|
@@ -702,8 +702,8 @@ class MongoRepository {
|
|
|
702
702
|
aggregateAuthorizePaymentAction(params) {
|
|
703
703
|
return __awaiter(this, void 0, void 0, function* () {
|
|
704
704
|
const statuses = yield Promise.all([
|
|
705
|
-
factory.actionStatusType.CanceledActionStatus,
|
|
706
705
|
factory.actionStatusType.CompletedActionStatus,
|
|
706
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
707
707
|
factory.actionStatusType.FailedActionStatus
|
|
708
708
|
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
709
709
|
var _a, _b;
|
|
@@ -721,6 +721,25 @@ class MongoRepository {
|
|
|
721
721
|
return { statuses };
|
|
722
722
|
});
|
|
723
723
|
}
|
|
724
|
+
aggregateUseAction(params) {
|
|
725
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
726
|
+
const statuses = yield Promise.all([
|
|
727
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
728
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
729
|
+
factory.actionStatusType.FailedActionStatus
|
|
730
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
731
|
+
var _a, _b;
|
|
732
|
+
const matchConditions = Object.assign({ startDate: {
|
|
733
|
+
$gte: params.startFrom,
|
|
734
|
+
$lte: params.startThrough
|
|
735
|
+
}, typeOf: { $eq: params.typeOf }, actionStatus: { $eq: actionStatus } }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
736
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
737
|
+
: undefined);
|
|
738
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
739
|
+
})));
|
|
740
|
+
return { statuses };
|
|
741
|
+
});
|
|
742
|
+
}
|
|
724
743
|
// tslint:disable-next-line:max-func-body-length
|
|
725
744
|
agggregateByStatus(params) {
|
|
726
745
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import { Connection, Model } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
export declare enum AggregationType {
|
|
4
|
+
AggregatePlaceOrder = "AggregatePlaceOrder",
|
|
5
|
+
AggregateAuthorizeEventServiceOfferAction = "AggregateAuthorizeEventServiceOfferAction",
|
|
6
|
+
AggregateAuthorizePaymentAction = "AggregateAuthorizePaymentAction",
|
|
7
|
+
AggregateOrder = "AggregateOrder",
|
|
8
|
+
AggregateReservation = "AggregateReservation",
|
|
9
|
+
AggregateUseAction = "AggregateUseAction"
|
|
10
|
+
}
|
|
11
|
+
export interface IAggregation {
|
|
12
|
+
typeOf: AggregationType;
|
|
13
|
+
project: {
|
|
14
|
+
id: string;
|
|
15
|
+
typeOf: factory.organizationType.Project;
|
|
16
|
+
};
|
|
17
|
+
aggregateDate: Date;
|
|
18
|
+
aggregateDuration: string;
|
|
19
|
+
aggregateStart: Date;
|
|
20
|
+
}
|
|
2
21
|
/**
|
|
3
22
|
* 集計リポジトリ
|
|
4
23
|
*/
|
|
5
24
|
export declare class MongoRepository {
|
|
6
25
|
readonly aggregationModel: typeof Model;
|
|
7
26
|
constructor(connection: Connection);
|
|
27
|
+
saveAggregation(params: IAggregation): Promise<any>;
|
|
8
28
|
}
|
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MongoRepository = void 0;
|
|
23
|
+
exports.MongoRepository = exports.AggregationType = void 0;
|
|
4
24
|
const aggregation_1 = require("./mongoose/model/aggregation");
|
|
25
|
+
var AggregationType;
|
|
26
|
+
(function (AggregationType) {
|
|
27
|
+
AggregationType["AggregatePlaceOrder"] = "AggregatePlaceOrder";
|
|
28
|
+
AggregationType["AggregateAuthorizeEventServiceOfferAction"] = "AggregateAuthorizeEventServiceOfferAction";
|
|
29
|
+
AggregationType["AggregateAuthorizePaymentAction"] = "AggregateAuthorizePaymentAction";
|
|
30
|
+
AggregationType["AggregateOrder"] = "AggregateOrder";
|
|
31
|
+
AggregationType["AggregateReservation"] = "AggregateReservation";
|
|
32
|
+
AggregationType["AggregateUseAction"] = "AggregateUseAction";
|
|
33
|
+
})(AggregationType = exports.AggregationType || (exports.AggregationType = {}));
|
|
5
34
|
/**
|
|
6
35
|
* 集計リポジトリ
|
|
7
36
|
*/
|
|
@@ -9,5 +38,26 @@ class MongoRepository {
|
|
|
9
38
|
constructor(connection) {
|
|
10
39
|
this.aggregationModel = connection.model(aggregation_1.modelName);
|
|
11
40
|
}
|
|
41
|
+
saveAggregation(params) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const { typeOf, project, aggregateDuration, aggregateStart } = params, setFields = __rest(params, ["typeOf", "project", "aggregateDuration", "aggregateStart"]);
|
|
44
|
+
const doc = yield this.aggregationModel.findOneAndUpdate({
|
|
45
|
+
typeOf: { $eq: params.typeOf },
|
|
46
|
+
'project.id': { $eq: params.project.id },
|
|
47
|
+
aggregateStart: { $eq: params.aggregateStart },
|
|
48
|
+
aggregateDuration: { $eq: params.aggregateDuration }
|
|
49
|
+
}, {
|
|
50
|
+
$setOnInsert: {
|
|
51
|
+
typeOf: params.typeOf,
|
|
52
|
+
project: params.project,
|
|
53
|
+
aggregateDuration: params.aggregateDuration,
|
|
54
|
+
aggregateStart: params.aggregateStart
|
|
55
|
+
},
|
|
56
|
+
$set: setFields
|
|
57
|
+
}, { upsert: true, new: true })
|
|
58
|
+
.exec();
|
|
59
|
+
return doc.toObject();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
12
62
|
}
|
|
13
63
|
exports.MongoRepository = MongoRepository;
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -923,7 +923,7 @@ class MongoRepository {
|
|
|
923
923
|
aggregateOrder(params) {
|
|
924
924
|
var _a, _b;
|
|
925
925
|
return __awaiter(this, void 0, void 0, function* () {
|
|
926
|
-
|
|
926
|
+
const aggregations = yield this.orderModel.aggregate([
|
|
927
927
|
{
|
|
928
928
|
$match: {
|
|
929
929
|
orderDate: {
|
|
@@ -951,9 +951,22 @@ class MongoRepository {
|
|
|
951
951
|
minPrice: { $min: '$price' },
|
|
952
952
|
avgPrice: { $avg: '$price' }
|
|
953
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
|
+
}
|
|
954
966
|
}
|
|
955
967
|
])
|
|
956
968
|
.exec();
|
|
969
|
+
return aggregations[0];
|
|
957
970
|
});
|
|
958
971
|
}
|
|
959
972
|
}
|
|
@@ -146,5 +146,15 @@ export declare class MongoRepository {
|
|
|
146
146
|
findByIdAndDelete(params: {
|
|
147
147
|
id: string;
|
|
148
148
|
}): Promise<void>;
|
|
149
|
-
aggregatePlaceOrder(params:
|
|
149
|
+
aggregatePlaceOrder(params: {
|
|
150
|
+
project?: {
|
|
151
|
+
id?: {
|
|
152
|
+
$ne?: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
startFrom: Date;
|
|
156
|
+
startThrough: Date;
|
|
157
|
+
typeOf: factory.transactionType;
|
|
158
|
+
}): Promise<IAggregatePlaceOrder>;
|
|
159
|
+
private agggregateByStatus;
|
|
150
160
|
}
|
|
@@ -600,140 +600,129 @@ class MongoRepository {
|
|
|
600
600
|
.exec();
|
|
601
601
|
});
|
|
602
602
|
}
|
|
603
|
-
// tslint:disable-next-line:max-func-body-length
|
|
604
603
|
aggregatePlaceOrder(params) {
|
|
605
604
|
return __awaiter(this, void 0, void 0, function* () {
|
|
606
605
|
const statuses = yield Promise.all([
|
|
607
606
|
factory.transactionStatusType.Canceled,
|
|
608
607
|
factory.transactionStatusType.Expired,
|
|
609
608
|
factory.transactionStatusType.Confirmed
|
|
610
|
-
// tslint:disable-next-line:max-func-body-length
|
|
611
609
|
].map((transactionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
612
|
-
var _a, _b
|
|
613
|
-
const matchConditions = {
|
|
614
|
-
'project.id': Object.assign({}, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
615
|
-
? { $ne: (_d = (_c = params.project) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$ne }
|
|
616
|
-
: undefined),
|
|
617
|
-
startDate: {
|
|
610
|
+
var _a, _b;
|
|
611
|
+
const matchConditions = Object.assign({ startDate: {
|
|
618
612
|
$gte: params.startFrom,
|
|
619
613
|
$lte: params.startThrough
|
|
620
|
-
},
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
614
|
+
}, 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')
|
|
615
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
616
|
+
: undefined);
|
|
617
|
+
return this.agggregateByStatus({ matchConditions, status: transactionStatus });
|
|
618
|
+
})));
|
|
619
|
+
return { statuses };
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
// tslint:disable-next-line:max-func-body-length
|
|
623
|
+
agggregateByStatus(params) {
|
|
624
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
625
|
+
const matchConditions = params.matchConditions;
|
|
626
|
+
const transactionStatus = params.status;
|
|
627
|
+
const aggregations = yield this.transactionModel.aggregate([
|
|
628
|
+
{
|
|
629
|
+
$match: matchConditions
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
$project: {
|
|
633
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
634
|
+
status: '$status',
|
|
635
|
+
startDate: '$startDate',
|
|
636
|
+
endDate: '$endDate',
|
|
637
|
+
typeOf: '$typeOf'
|
|
624
638
|
}
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
{
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
$
|
|
632
|
-
|
|
633
|
-
$subtract: ['$endDate', '$startDate']
|
|
634
|
-
},
|
|
635
|
-
status: '$status',
|
|
636
|
-
startDate: '$startDate',
|
|
637
|
-
endDate: '$endDate',
|
|
638
|
-
typeOf: '$typeOf'
|
|
639
|
-
}
|
|
640
|
-
},
|
|
641
|
-
{
|
|
642
|
-
$group: {
|
|
643
|
-
_id: '$typeOf',
|
|
644
|
-
transactionCount: { $sum: 1 },
|
|
645
|
-
maxDuration: {
|
|
646
|
-
$max: '$duration'
|
|
647
|
-
},
|
|
648
|
-
minDuration: {
|
|
649
|
-
$min: '$duration'
|
|
650
|
-
},
|
|
651
|
-
avgDuration: {
|
|
652
|
-
$avg: '$duration'
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
},
|
|
656
|
-
{
|
|
657
|
-
$project: {
|
|
658
|
-
_id: 0,
|
|
659
|
-
transactionCount: '$transactionCount',
|
|
660
|
-
avgDuration: '$avgDuration',
|
|
661
|
-
maxDuration: '$maxDuration',
|
|
662
|
-
minDuration: '$minDuration'
|
|
663
|
-
}
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
$group: {
|
|
642
|
+
_id: '$typeOf',
|
|
643
|
+
transactionCount: { $sum: 1 },
|
|
644
|
+
maxDuration: { $max: '$duration' },
|
|
645
|
+
minDuration: { $min: '$duration' },
|
|
646
|
+
avgDuration: { $avg: '$duration' }
|
|
664
647
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
transactionCount: 0,
|
|
674
|
-
avgDuration: 0,
|
|
675
|
-
maxDuration: 0,
|
|
676
|
-
minDuration: 0,
|
|
677
|
-
percentilesDuration: percents.map((percent) => {
|
|
678
|
-
return {
|
|
679
|
-
name: String(percent),
|
|
680
|
-
value: 0
|
|
681
|
-
};
|
|
682
|
-
})
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
const ranks4percentile = percents.map((percentile) => {
|
|
687
|
-
return {
|
|
688
|
-
percentile,
|
|
689
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
690
|
-
rank: Math.floor(aggregations[0].transactionCount * percentile / 100)
|
|
691
|
-
};
|
|
692
|
-
});
|
|
693
|
-
const aggregations2 = yield this.transactionModel.aggregate([
|
|
694
|
-
{
|
|
695
|
-
$match: matchConditions
|
|
696
|
-
},
|
|
697
|
-
{
|
|
698
|
-
$project: {
|
|
699
|
-
duration: {
|
|
700
|
-
$subtract: ['$endDate', '$startDate']
|
|
701
|
-
},
|
|
702
|
-
status: '$status',
|
|
703
|
-
startDate: '$startDate',
|
|
704
|
-
endDate: '$endDate',
|
|
705
|
-
typeOf: '$typeOf'
|
|
706
|
-
}
|
|
707
|
-
},
|
|
708
|
-
{ $sort: { duration: 1 } },
|
|
709
|
-
{
|
|
710
|
-
$group: {
|
|
711
|
-
_id: '$typeOf',
|
|
712
|
-
durations: { $push: '$duration' }
|
|
713
|
-
}
|
|
714
|
-
},
|
|
715
|
-
{
|
|
716
|
-
$project: {
|
|
717
|
-
_id: 0,
|
|
718
|
-
avgSmallDuration: '$avgSmallDuration',
|
|
719
|
-
avgMediumDuration: '$avgMediumDuration',
|
|
720
|
-
avgLargeDuration: '$avgLargeDuration',
|
|
721
|
-
percentilesDuration: ranks4percentile.map((rank) => {
|
|
722
|
-
return {
|
|
723
|
-
name: String(rank.percentile),
|
|
724
|
-
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
725
|
-
};
|
|
726
|
-
})
|
|
727
|
-
}
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
$project: {
|
|
651
|
+
_id: 0,
|
|
652
|
+
transactionCount: '$transactionCount',
|
|
653
|
+
avgDuration: '$avgDuration',
|
|
654
|
+
maxDuration: '$maxDuration',
|
|
655
|
+
minDuration: '$minDuration'
|
|
728
656
|
}
|
|
729
|
-
|
|
730
|
-
|
|
657
|
+
}
|
|
658
|
+
])
|
|
659
|
+
.exec();
|
|
660
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
661
|
+
const percents = [50, 95, 99];
|
|
662
|
+
if (aggregations.length === 0) {
|
|
731
663
|
return {
|
|
732
664
|
status: transactionStatus,
|
|
733
|
-
aggregation:
|
|
665
|
+
aggregation: {
|
|
666
|
+
transactionCount: 0,
|
|
667
|
+
avgDuration: 0,
|
|
668
|
+
maxDuration: 0,
|
|
669
|
+
minDuration: 0,
|
|
670
|
+
percentilesDuration: percents.map((percent) => {
|
|
671
|
+
return {
|
|
672
|
+
name: String(percent),
|
|
673
|
+
value: 0
|
|
674
|
+
};
|
|
675
|
+
})
|
|
676
|
+
}
|
|
734
677
|
};
|
|
735
|
-
}
|
|
736
|
-
|
|
678
|
+
}
|
|
679
|
+
const ranks4percentile = percents.map((percentile) => {
|
|
680
|
+
return {
|
|
681
|
+
percentile,
|
|
682
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
683
|
+
rank: Math.floor(aggregations[0].transactionCount * percentile / 100)
|
|
684
|
+
};
|
|
685
|
+
});
|
|
686
|
+
const aggregations2 = yield this.transactionModel.aggregate([
|
|
687
|
+
{
|
|
688
|
+
$match: matchConditions
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
$project: {
|
|
692
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
693
|
+
status: '$status',
|
|
694
|
+
startDate: '$startDate',
|
|
695
|
+
endDate: '$endDate',
|
|
696
|
+
typeOf: '$typeOf'
|
|
697
|
+
}
|
|
698
|
+
},
|
|
699
|
+
{ $sort: { duration: 1 } },
|
|
700
|
+
{
|
|
701
|
+
$group: {
|
|
702
|
+
_id: '$typeOf',
|
|
703
|
+
durations: { $push: '$duration' }
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
$project: {
|
|
708
|
+
_id: 0,
|
|
709
|
+
avgSmallDuration: '$avgSmallDuration',
|
|
710
|
+
avgMediumDuration: '$avgMediumDuration',
|
|
711
|
+
avgLargeDuration: '$avgLargeDuration',
|
|
712
|
+
percentilesDuration: ranks4percentile.map((rank) => {
|
|
713
|
+
return {
|
|
714
|
+
name: String(rank.percentile),
|
|
715
|
+
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
716
|
+
};
|
|
717
|
+
})
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
])
|
|
721
|
+
.exec();
|
|
722
|
+
return {
|
|
723
|
+
status: transactionStatus,
|
|
724
|
+
aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
|
|
725
|
+
};
|
|
737
726
|
});
|
|
738
727
|
}
|
|
739
728
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
2
|
+
import { MongoRepository as AggregationRepo } from '../../repo/aggregation';
|
|
3
|
+
import { MongoRepository as OrderRepo } from '../../repo/order';
|
|
4
|
+
import { MongoRepository as ReservationRepo } from '../../repo/reservation';
|
|
5
|
+
import { MongoRepository as TransactionRepo } from '../../repo/transaction';
|
|
6
|
+
/**
|
|
7
|
+
* 注文取引集計
|
|
8
|
+
*/
|
|
9
|
+
declare function aggregatePlaceOrder(params: {
|
|
10
|
+
aggregationDays: number;
|
|
11
|
+
excludedProjectId?: string;
|
|
12
|
+
}): (repos: {
|
|
13
|
+
agregation: AggregationRepo;
|
|
14
|
+
transaction: TransactionRepo;
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* 興行オファー承認アクション集計
|
|
18
|
+
*/
|
|
19
|
+
declare function aggregateAuthorizeEventServiceOfferAction(params: {
|
|
20
|
+
aggregationDays: number;
|
|
21
|
+
excludedProjectId?: string;
|
|
22
|
+
}): (repos: {
|
|
23
|
+
agregation: AggregationRepo;
|
|
24
|
+
action: ActionRepo;
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* 決済承認アクション集計
|
|
28
|
+
*/
|
|
29
|
+
declare function aggregateAuthorizePaymentAction(params: {
|
|
30
|
+
aggregationDays: number;
|
|
31
|
+
excludedProjectId?: string;
|
|
32
|
+
}): (repos: {
|
|
33
|
+
agregation: AggregationRepo;
|
|
34
|
+
action: ActionRepo;
|
|
35
|
+
}) => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* 使用アクション集計
|
|
38
|
+
*/
|
|
39
|
+
declare function aggregateUseAction(params: {
|
|
40
|
+
aggregationDays: number;
|
|
41
|
+
excludedProjectId?: string;
|
|
42
|
+
}): (repos: {
|
|
43
|
+
agregation: AggregationRepo;
|
|
44
|
+
action: ActionRepo;
|
|
45
|
+
}) => Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* 注文集計
|
|
48
|
+
*/
|
|
49
|
+
declare function aggregateOrder(params: {
|
|
50
|
+
aggregationDays: number;
|
|
51
|
+
excludedProjectId?: string;
|
|
52
|
+
}): (repos: {
|
|
53
|
+
agregation: AggregationRepo;
|
|
54
|
+
order: OrderRepo;
|
|
55
|
+
}) => Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* 予約集計
|
|
58
|
+
*/
|
|
59
|
+
declare function aggregateReservation(params: {
|
|
60
|
+
aggregationDays: number;
|
|
61
|
+
excludedProjectId?: string;
|
|
62
|
+
}): (repos: {
|
|
63
|
+
agregation: AggregationRepo;
|
|
64
|
+
reservation: ReservationRepo;
|
|
65
|
+
}) => Promise<void>;
|
|
66
|
+
export { aggregateAuthorizeEventServiceOfferAction, aggregateAuthorizePaymentAction, aggregateOrder, aggregatePlaceOrder, aggregateReservation, aggregateUseAction };
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.aggregateUseAction = exports.aggregateReservation = exports.aggregatePlaceOrder = exports.aggregateOrder = exports.aggregateAuthorizePaymentAction = exports.aggregateAuthorizeEventServiceOfferAction = void 0;
|
|
13
|
+
const createDebug = require("debug");
|
|
14
|
+
const moment = require("moment-timezone");
|
|
15
|
+
const factory = require("../../factory");
|
|
16
|
+
const aggregation_1 = require("../../repo/aggregation");
|
|
17
|
+
const debug = createDebug('chevre-domain:service:aggregation:system');
|
|
18
|
+
/**
|
|
19
|
+
* 注文取引集計
|
|
20
|
+
*/
|
|
21
|
+
function aggregatePlaceOrder(params) {
|
|
22
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
var _a;
|
|
24
|
+
const aggregateDate = new Date();
|
|
25
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
26
|
+
.toISOString();
|
|
27
|
+
let i = -1;
|
|
28
|
+
while (i < params.aggregationDays) {
|
|
29
|
+
i += 1;
|
|
30
|
+
const startFrom = moment()
|
|
31
|
+
// .tz('Asia/Tokyo')
|
|
32
|
+
.add(-i, 'days')
|
|
33
|
+
.startOf('day')
|
|
34
|
+
.toDate();
|
|
35
|
+
const startThrough = moment()
|
|
36
|
+
// .tz('Asia/Tokyo')
|
|
37
|
+
.add(-i, 'days')
|
|
38
|
+
.endOf('day')
|
|
39
|
+
.toDate();
|
|
40
|
+
const aggregateResult = yield repos.transaction.aggregatePlaceOrder({
|
|
41
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
42
|
+
startFrom,
|
|
43
|
+
startThrough,
|
|
44
|
+
typeOf: factory.transactionType.PlaceOrder
|
|
45
|
+
});
|
|
46
|
+
debug('aggregatePlaceOrder:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
47
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregatePlaceOrder, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.aggregatePlaceOrder = aggregatePlaceOrder;
|
|
52
|
+
/**
|
|
53
|
+
* 興行オファー承認アクション集計
|
|
54
|
+
*/
|
|
55
|
+
function aggregateAuthorizeEventServiceOfferAction(params) {
|
|
56
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a;
|
|
58
|
+
const aggregateDate = new Date();
|
|
59
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
60
|
+
.toISOString();
|
|
61
|
+
let i = -1;
|
|
62
|
+
while (i < params.aggregationDays) {
|
|
63
|
+
i += 1;
|
|
64
|
+
const startFrom = moment()
|
|
65
|
+
// .tz('Asia/Tokyo')
|
|
66
|
+
.add(-i, 'days')
|
|
67
|
+
.startOf('day')
|
|
68
|
+
.toDate();
|
|
69
|
+
const startThrough = moment()
|
|
70
|
+
// .tz('Asia/Tokyo')
|
|
71
|
+
.add(-i, 'days')
|
|
72
|
+
.endOf('day')
|
|
73
|
+
.toDate();
|
|
74
|
+
const aggregateResult = yield repos.action.aggregateAuthorizeEventServiceOfferAction({
|
|
75
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
76
|
+
startFrom,
|
|
77
|
+
startThrough,
|
|
78
|
+
typeOf: factory.actionType.AuthorizeAction
|
|
79
|
+
});
|
|
80
|
+
debug('aggregateAuthorizeEventServiceOfferAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
81
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateAuthorizeEventServiceOfferAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
exports.aggregateAuthorizeEventServiceOfferAction = aggregateAuthorizeEventServiceOfferAction;
|
|
86
|
+
/**
|
|
87
|
+
* 決済承認アクション集計
|
|
88
|
+
*/
|
|
89
|
+
function aggregateAuthorizePaymentAction(params) {
|
|
90
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
var _a;
|
|
92
|
+
const aggregateDate = new Date();
|
|
93
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
94
|
+
.toISOString();
|
|
95
|
+
let i = -1;
|
|
96
|
+
while (i < params.aggregationDays) {
|
|
97
|
+
i += 1;
|
|
98
|
+
const startFrom = moment()
|
|
99
|
+
// .tz('Asia/Tokyo')
|
|
100
|
+
.add(-i, 'days')
|
|
101
|
+
.startOf('day')
|
|
102
|
+
.toDate();
|
|
103
|
+
const startThrough = moment()
|
|
104
|
+
// .tz('Asia/Tokyo')
|
|
105
|
+
.add(-i, 'days')
|
|
106
|
+
.endOf('day')
|
|
107
|
+
.toDate();
|
|
108
|
+
const aggregateResult = yield repos.action.aggregateAuthorizePaymentAction({
|
|
109
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
110
|
+
startFrom,
|
|
111
|
+
startThrough,
|
|
112
|
+
typeOf: factory.actionType.AuthorizeAction
|
|
113
|
+
});
|
|
114
|
+
debug('aggregateAuthorizePaymentAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
115
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateAuthorizePaymentAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
exports.aggregateAuthorizePaymentAction = aggregateAuthorizePaymentAction;
|
|
120
|
+
/**
|
|
121
|
+
* 使用アクション集計
|
|
122
|
+
*/
|
|
123
|
+
function aggregateUseAction(params) {
|
|
124
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
var _a;
|
|
126
|
+
const aggregateDate = new Date();
|
|
127
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
128
|
+
.toISOString();
|
|
129
|
+
let i = -1;
|
|
130
|
+
while (i < params.aggregationDays) {
|
|
131
|
+
i += 1;
|
|
132
|
+
const startFrom = moment()
|
|
133
|
+
// .tz('Asia/Tokyo')
|
|
134
|
+
.add(-i, 'days')
|
|
135
|
+
.startOf('day')
|
|
136
|
+
.toDate();
|
|
137
|
+
const startThrough = moment()
|
|
138
|
+
// .tz('Asia/Tokyo')
|
|
139
|
+
.add(-i, 'days')
|
|
140
|
+
.endOf('day')
|
|
141
|
+
.toDate();
|
|
142
|
+
const aggregateResult = yield repos.action.aggregateUseAction({
|
|
143
|
+
project: { id: { $ne: params.excludedProjectId } },
|
|
144
|
+
startFrom,
|
|
145
|
+
startThrough,
|
|
146
|
+
typeOf: factory.actionType.UseAction
|
|
147
|
+
});
|
|
148
|
+
debug('aggregateUseAction:result', aggregateResult, (_a = aggregateResult.statuses[0]) === null || _a === void 0 ? void 0 : _a.aggregation.percentilesDuration, startFrom);
|
|
149
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateUseAction, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: startFrom, aggregateDate }, aggregateResult));
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
exports.aggregateUseAction = aggregateUseAction;
|
|
154
|
+
/**
|
|
155
|
+
* 注文集計
|
|
156
|
+
*/
|
|
157
|
+
function aggregateOrder(params) {
|
|
158
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const aggregateDate = new Date();
|
|
160
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
161
|
+
.toISOString();
|
|
162
|
+
let i = -1;
|
|
163
|
+
while (i < params.aggregationDays) {
|
|
164
|
+
i += 1;
|
|
165
|
+
const orderDateFrom = moment()
|
|
166
|
+
// .tz('Asia/Tokyo')
|
|
167
|
+
.add(-i, 'days')
|
|
168
|
+
.startOf('day')
|
|
169
|
+
.toDate();
|
|
170
|
+
const orderDateThrough = moment()
|
|
171
|
+
// .tz('Asia/Tokyo')
|
|
172
|
+
.add(-i, 'days')
|
|
173
|
+
.endOf('day')
|
|
174
|
+
.toDate();
|
|
175
|
+
const aggregateResult = yield repos.order.aggregateOrder({
|
|
176
|
+
orderDate: {
|
|
177
|
+
$gte: orderDateFrom,
|
|
178
|
+
$lte: orderDateThrough
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
debug('aggregateOrder:result', aggregateResult);
|
|
182
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateOrder, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: orderDateFrom, aggregateDate }, aggregateResult));
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
exports.aggregateOrder = aggregateOrder;
|
|
187
|
+
/**
|
|
188
|
+
* 予約集計
|
|
189
|
+
*/
|
|
190
|
+
function aggregateReservation(params) {
|
|
191
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
const aggregateDate = new Date();
|
|
193
|
+
const aggregateDuration = moment.duration(1, 'days')
|
|
194
|
+
.toISOString();
|
|
195
|
+
let i = -1;
|
|
196
|
+
while (i < params.aggregationDays) {
|
|
197
|
+
i += 1;
|
|
198
|
+
const bookingFrom = moment()
|
|
199
|
+
// .tz('Asia/Tokyo')
|
|
200
|
+
.add(-i, 'days')
|
|
201
|
+
.startOf('day')
|
|
202
|
+
.toDate();
|
|
203
|
+
const bookingThrough = moment()
|
|
204
|
+
// .tz('Asia/Tokyo')
|
|
205
|
+
.add(-i, 'days')
|
|
206
|
+
.endOf('day')
|
|
207
|
+
.toDate();
|
|
208
|
+
// i日前の予約検索
|
|
209
|
+
const reservationCount = yield repos.reservation.count({
|
|
210
|
+
typeOf: factory.reservationType.EventReservation,
|
|
211
|
+
reservationStatus: { $eq: factory.reservationStatusType.ReservationConfirmed },
|
|
212
|
+
bookingFrom,
|
|
213
|
+
bookingThrough
|
|
214
|
+
});
|
|
215
|
+
const aggregateResult = { reservationCount };
|
|
216
|
+
yield repos.agregation.saveAggregation(Object.assign({ typeOf: aggregation_1.AggregationType.AggregateReservation, project: { id: '*', typeOf: factory.organizationType.Project }, aggregateDuration, aggregateStart: bookingFrom, aggregateDate }, aggregateResult));
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
exports.aggregateReservation = aggregateReservation;
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as EventAggregation from './aggregation/event';
|
|
5
5
|
import * as ProjectAggregation from './aggregation/project';
|
|
6
|
+
import * as SystemAggregation from './aggregation/system';
|
|
6
7
|
export import event = EventAggregation;
|
|
7
8
|
export import project = ProjectAggregation;
|
|
9
|
+
export import system = SystemAggregation;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.project = exports.event = void 0;
|
|
3
|
+
exports.system = exports.project = exports.event = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 集計サービス
|
|
6
6
|
*/
|
|
7
7
|
const EventAggregation = require("./aggregation/event");
|
|
8
8
|
const ProjectAggregation = require("./aggregation/project");
|
|
9
|
+
const SystemAggregation = require("./aggregation/system");
|
|
9
10
|
exports.event = EventAggregation;
|
|
10
11
|
exports.project = ProjectAggregation;
|
|
12
|
+
exports.system = SystemAggregation;
|
package/package.json
CHANGED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment-timezone';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: <string>process.env.PROJECT_ID };
|
|
8
|
-
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
const AGGREGATE_DAYS = Number(process.env.AGGREGATE_DAYS);
|
|
10
|
-
|
|
11
|
-
interface IAggregation {
|
|
12
|
-
typeOf: 'AggregateAuthorizeEventServiceOfferAction';
|
|
13
|
-
project: { id: string; typeOf: chevre.factory.organizationType.Project };
|
|
14
|
-
aggregateDate: Date;
|
|
15
|
-
aggregateDuration: string;
|
|
16
|
-
aggregateStart: Date;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function main() {
|
|
20
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
21
|
-
|
|
22
|
-
const now: Date = new Date();
|
|
23
|
-
|
|
24
|
-
const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
|
|
25
|
-
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
26
|
-
|
|
27
|
-
let i = 0;
|
|
28
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
29
|
-
while (i < AGGREGATE_DAYS) {
|
|
30
|
-
i += 1;
|
|
31
|
-
|
|
32
|
-
const startFrom: Date = moment()
|
|
33
|
-
// .tz('Asia/Tokyo')
|
|
34
|
-
.add(-i, 'days')
|
|
35
|
-
.startOf('day')
|
|
36
|
-
.toDate();
|
|
37
|
-
const startThrough: Date = moment()
|
|
38
|
-
// .tz('Asia/Tokyo')
|
|
39
|
-
.add(-i, 'days')
|
|
40
|
-
.endOf('day')
|
|
41
|
-
.toDate();
|
|
42
|
-
const aggregateResult = await actionRepo.aggregateAuthorizeEventServiceOfferAction({
|
|
43
|
-
project: { id: <any>{ $ne: EXCLUDED_PROJECT_ID } },
|
|
44
|
-
startFrom,
|
|
45
|
-
startThrough,
|
|
46
|
-
typeOf: chevre.factory.actionType.AuthorizeAction
|
|
47
|
-
});
|
|
48
|
-
console.log('aggregateResult', aggregateResult, aggregateResult.statuses[0]?.aggregation.percentilesDuration, startFrom);
|
|
49
|
-
|
|
50
|
-
const aggregation: IAggregation = {
|
|
51
|
-
typeOf: 'AggregateAuthorizeEventServiceOfferAction',
|
|
52
|
-
project: { id: '*', typeOf: chevre.factory.organizationType.Project },
|
|
53
|
-
aggregateDuration: moment.duration(1, 'days')
|
|
54
|
-
.toISOString(),
|
|
55
|
-
aggregateStart: startFrom,
|
|
56
|
-
aggregateDate: now,
|
|
57
|
-
...aggregateResult
|
|
58
|
-
};
|
|
59
|
-
const { typeOf, project, aggregateDuration, aggregateStart, ...setFields } = aggregation;
|
|
60
|
-
const doc = await aggregationRepo.aggregationModel.findOneAndUpdate(
|
|
61
|
-
{
|
|
62
|
-
typeOf: { $eq: aggregation.typeOf },
|
|
63
|
-
'project.id': { $eq: aggregation.project.id },
|
|
64
|
-
aggregateStart: { $eq: aggregation.aggregateStart },
|
|
65
|
-
aggregateDuration: { $eq: aggregation.aggregateDuration }
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
$setOnInsert: {
|
|
69
|
-
typeOf: aggregation.typeOf,
|
|
70
|
-
project: aggregation.project,
|
|
71
|
-
aggregateDuration: aggregation.aggregateDuration,
|
|
72
|
-
aggregateStart: aggregation.aggregateStart
|
|
73
|
-
},
|
|
74
|
-
$set: setFields
|
|
75
|
-
},
|
|
76
|
-
{ upsert: true, new: true }
|
|
77
|
-
)
|
|
78
|
-
.exec();
|
|
79
|
-
console.log(doc);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
main()
|
|
84
|
-
.then(() => {
|
|
85
|
-
console.log('success!');
|
|
86
|
-
})
|
|
87
|
-
.catch(console.error);
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment-timezone';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: <string>process.env.PROJECT_ID };
|
|
8
|
-
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
const AGGREGATE_DAYS = Number(process.env.AGGREGATE_DAYS);
|
|
10
|
-
|
|
11
|
-
interface IAggregation {
|
|
12
|
-
typeOf: 'AggregateAuthorizePaymentAction';
|
|
13
|
-
project: { id: string; typeOf: chevre.factory.organizationType.Project };
|
|
14
|
-
aggregateDate: Date;
|
|
15
|
-
aggregateDuration: string;
|
|
16
|
-
aggregateStart: Date;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function main() {
|
|
20
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
21
|
-
|
|
22
|
-
const now: Date = new Date();
|
|
23
|
-
|
|
24
|
-
const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
|
|
25
|
-
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
26
|
-
|
|
27
|
-
let i = 0;
|
|
28
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
29
|
-
while (i < AGGREGATE_DAYS) {
|
|
30
|
-
i += 1;
|
|
31
|
-
|
|
32
|
-
const startFrom: Date = moment()
|
|
33
|
-
// .tz('Asia/Tokyo')
|
|
34
|
-
.add(-i, 'days')
|
|
35
|
-
.startOf('day')
|
|
36
|
-
.toDate();
|
|
37
|
-
const startThrough: Date = moment()
|
|
38
|
-
// .tz('Asia/Tokyo')
|
|
39
|
-
.add(-i, 'days')
|
|
40
|
-
.endOf('day')
|
|
41
|
-
.toDate();
|
|
42
|
-
const aggregateResult = await actionRepo.aggregateAuthorizePaymentAction({
|
|
43
|
-
project: { id: <any>{ $ne: EXCLUDED_PROJECT_ID } },
|
|
44
|
-
startFrom,
|
|
45
|
-
startThrough,
|
|
46
|
-
typeOf: chevre.factory.actionType.AuthorizeAction
|
|
47
|
-
});
|
|
48
|
-
console.log('aggregateResult', aggregateResult, aggregateResult.statuses[0]?.aggregation.percentilesDuration, startFrom);
|
|
49
|
-
|
|
50
|
-
const aggregation: IAggregation = {
|
|
51
|
-
typeOf: 'AggregateAuthorizePaymentAction',
|
|
52
|
-
project: { id: '*', typeOf: chevre.factory.organizationType.Project },
|
|
53
|
-
aggregateDuration: moment.duration(1, 'days')
|
|
54
|
-
.toISOString(),
|
|
55
|
-
aggregateStart: startFrom,
|
|
56
|
-
aggregateDate: now,
|
|
57
|
-
...aggregateResult
|
|
58
|
-
};
|
|
59
|
-
const { typeOf, project, aggregateDuration, aggregateStart, ...setFields } = aggregation;
|
|
60
|
-
const doc = await aggregationRepo.aggregationModel.findOneAndUpdate(
|
|
61
|
-
{
|
|
62
|
-
typeOf: { $eq: aggregation.typeOf },
|
|
63
|
-
'project.id': { $eq: aggregation.project.id },
|
|
64
|
-
aggregateStart: { $eq: aggregation.aggregateStart },
|
|
65
|
-
aggregateDuration: { $eq: aggregation.aggregateDuration }
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
$setOnInsert: {
|
|
69
|
-
typeOf: aggregation.typeOf,
|
|
70
|
-
project: aggregation.project,
|
|
71
|
-
aggregateDuration: aggregation.aggregateDuration,
|
|
72
|
-
aggregateStart: aggregation.aggregateStart
|
|
73
|
-
},
|
|
74
|
-
$set: setFields
|
|
75
|
-
},
|
|
76
|
-
{ upsert: true, new: true }
|
|
77
|
-
)
|
|
78
|
-
.exec();
|
|
79
|
-
console.log(doc);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
main()
|
|
84
|
-
.then(() => {
|
|
85
|
-
console.log('success!');
|
|
86
|
-
})
|
|
87
|
-
.catch(console.error);
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment-timezone';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: <string>process.env.PROJECT_ID };
|
|
8
|
-
interface IAggregation {
|
|
9
|
-
typeOf: 'AggregateOrder';
|
|
10
|
-
project: { id: string; typeOf: chevre.factory.organizationType.Project };
|
|
11
|
-
aggregateDate: Date;
|
|
12
|
-
aggregateDuration: string;
|
|
13
|
-
aggregateStart: Date;
|
|
14
|
-
orderCount: number;
|
|
15
|
-
acceptedOfferCount: number;
|
|
16
|
-
avgAcceptedOfferCount: number;
|
|
17
|
-
totalPrice: number;
|
|
18
|
-
maxPrice: number;
|
|
19
|
-
minPrice: number;
|
|
20
|
-
avgPrice: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function main() {
|
|
24
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
25
|
-
|
|
26
|
-
const now: Date = new Date();
|
|
27
|
-
|
|
28
|
-
const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
|
|
29
|
-
const orderRepo = new chevre.repository.Order(mongoose.connection);
|
|
30
|
-
|
|
31
|
-
let i = 0;
|
|
32
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
33
|
-
while (i < 365) {
|
|
34
|
-
i += 1;
|
|
35
|
-
|
|
36
|
-
const orderDateFrom: Date = moment()
|
|
37
|
-
// .tz('Asia/Tokyo')
|
|
38
|
-
.add(-i, 'days')
|
|
39
|
-
.startOf('day')
|
|
40
|
-
.toDate();
|
|
41
|
-
const orderDateThrough: Date = moment()
|
|
42
|
-
// .tz('Asia/Tokyo')
|
|
43
|
-
.add(-i, 'days')
|
|
44
|
-
.endOf('day')
|
|
45
|
-
.toDate();
|
|
46
|
-
// console.log(bookingFrom, bookingThrough);
|
|
47
|
-
|
|
48
|
-
const aggregateResult = await orderRepo.aggregateOrder({
|
|
49
|
-
orderDate: {
|
|
50
|
-
$gte: orderDateFrom,
|
|
51
|
-
$lte: orderDateThrough
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
console.log('aggregateResult', aggregateResult);
|
|
55
|
-
|
|
56
|
-
const aggregation: IAggregation = {
|
|
57
|
-
typeOf: 'AggregateOrder',
|
|
58
|
-
project: { id: '*', typeOf: chevre.factory.organizationType.Project },
|
|
59
|
-
aggregateDuration: moment.duration(1, 'days')
|
|
60
|
-
.toISOString(),
|
|
61
|
-
aggregateStart: orderDateFrom,
|
|
62
|
-
aggregateDate: now,
|
|
63
|
-
orderCount: (aggregateResult.length > 0) ? aggregateResult[0].orderCount : 0,
|
|
64
|
-
acceptedOfferCount: (aggregateResult.length > 0) ? aggregateResult[0].acceptedOfferCount : 0,
|
|
65
|
-
avgAcceptedOfferCount: (aggregateResult.length > 0) ? aggregateResult[0].avgAcceptedOfferCount : 0,
|
|
66
|
-
totalPrice: (aggregateResult.length > 0) ? aggregateResult[0].totalPrice : 0,
|
|
67
|
-
maxPrice: (aggregateResult.length > 0) ? aggregateResult[0].maxPrice : 0,
|
|
68
|
-
minPrice: (aggregateResult.length > 0) ? aggregateResult[0].minPrice : 0,
|
|
69
|
-
avgPrice: (aggregateResult.length > 0) ? aggregateResult[0].avgPrice : 0
|
|
70
|
-
};
|
|
71
|
-
const {
|
|
72
|
-
avgAcceptedOfferCount,
|
|
73
|
-
totalPrice,
|
|
74
|
-
maxPrice,
|
|
75
|
-
minPrice,
|
|
76
|
-
avgPrice,
|
|
77
|
-
acceptedOfferCount,
|
|
78
|
-
orderCount,
|
|
79
|
-
aggregateDate,
|
|
80
|
-
...setOnInsert
|
|
81
|
-
} = aggregation;
|
|
82
|
-
const doc = await aggregationRepo.aggregationModel.findOneAndUpdate(
|
|
83
|
-
{
|
|
84
|
-
typeOf: { $eq: aggregation.typeOf },
|
|
85
|
-
'project.id': { $eq: aggregation.project.id },
|
|
86
|
-
aggregateStart: { $eq: aggregation.aggregateStart },
|
|
87
|
-
aggregateDuration: { $eq: aggregation.aggregateDuration }
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
$setOnInsert: setOnInsert,
|
|
91
|
-
$set: {
|
|
92
|
-
avgAcceptedOfferCount,
|
|
93
|
-
totalPrice,
|
|
94
|
-
maxPrice,
|
|
95
|
-
minPrice,
|
|
96
|
-
avgPrice,
|
|
97
|
-
acceptedOfferCount,
|
|
98
|
-
orderCount,
|
|
99
|
-
aggregateDate
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
{ upsert: true }
|
|
103
|
-
)
|
|
104
|
-
.exec();
|
|
105
|
-
console.log(doc);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
main()
|
|
110
|
-
.then(() => {
|
|
111
|
-
console.log('success!');
|
|
112
|
-
})
|
|
113
|
-
.catch(console.error);
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment-timezone';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: <string>process.env.PROJECT_ID };
|
|
8
|
-
interface IAggregation {
|
|
9
|
-
typeOf: 'AggregateReservation';
|
|
10
|
-
project: { id: string; typeOf: chevre.factory.organizationType.Project };
|
|
11
|
-
aggregateDate: Date;
|
|
12
|
-
aggregateDuration: string;
|
|
13
|
-
aggregateStart: Date;
|
|
14
|
-
// bookingTime: Date;
|
|
15
|
-
reservationCount: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async function main() {
|
|
19
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
20
|
-
|
|
21
|
-
const now: Date = new Date();
|
|
22
|
-
|
|
23
|
-
const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
|
|
24
|
-
const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
|
|
25
|
-
|
|
26
|
-
let i = 0;
|
|
27
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
28
|
-
while (i < 365) {
|
|
29
|
-
i += 1;
|
|
30
|
-
|
|
31
|
-
const bookingFrom: Date = moment()
|
|
32
|
-
// .tz('Asia/Tokyo')
|
|
33
|
-
.add(-i, 'days')
|
|
34
|
-
.startOf('day')
|
|
35
|
-
.toDate();
|
|
36
|
-
const bookingThrough: Date = moment()
|
|
37
|
-
// .tz('Asia/Tokyo')
|
|
38
|
-
.add(-i, 'days')
|
|
39
|
-
.endOf('day')
|
|
40
|
-
.toDate();
|
|
41
|
-
// console.log(bookingFrom, bookingThrough);
|
|
42
|
-
|
|
43
|
-
// i日前の予約検索
|
|
44
|
-
const searchReservationCountResult = await reservationRepo.count({
|
|
45
|
-
typeOf: chevre.factory.reservationType.EventReservation,
|
|
46
|
-
reservationStatus: { $eq: chevre.factory.reservationStatusType.ReservationConfirmed },
|
|
47
|
-
bookingFrom,
|
|
48
|
-
bookingThrough
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const aggregation: IAggregation = {
|
|
52
|
-
typeOf: 'AggregateReservation',
|
|
53
|
-
project: { id: '*', typeOf: chevre.factory.organizationType.Project },
|
|
54
|
-
aggregateDuration: moment.duration(1, 'days')
|
|
55
|
-
.toISOString(),
|
|
56
|
-
aggregateStart: bookingFrom,
|
|
57
|
-
aggregateDate: now,
|
|
58
|
-
reservationCount: searchReservationCountResult
|
|
59
|
-
};
|
|
60
|
-
console.log(aggregation);
|
|
61
|
-
const { reservationCount, aggregateDate, ...setOnInsert } = aggregation;
|
|
62
|
-
const doc = await aggregationRepo.aggregationModel.findOneAndUpdate(
|
|
63
|
-
{
|
|
64
|
-
typeOf: { $eq: aggregation.typeOf },
|
|
65
|
-
'project.id': { $eq: aggregation.project.id },
|
|
66
|
-
aggregateStart: { $eq: aggregation.aggregateStart },
|
|
67
|
-
aggregateDuration: { $eq: aggregation.aggregateDuration }
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
$setOnInsert: setOnInsert,
|
|
71
|
-
$set: { aggregateDate, reservationCount }
|
|
72
|
-
},
|
|
73
|
-
{ upsert: true }
|
|
74
|
-
)
|
|
75
|
-
.exec();
|
|
76
|
-
console.log(doc);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
main()
|
|
81
|
-
.then(() => {
|
|
82
|
-
console.log('success!');
|
|
83
|
-
})
|
|
84
|
-
.catch(console.error);
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment-timezone';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: <string>process.env.PROJECT_ID };
|
|
8
|
-
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
const AGGREGATE_DAYS = Number(process.env.AGGREGATE_DAYS);
|
|
10
|
-
|
|
11
|
-
interface IAggregation {
|
|
12
|
-
typeOf: 'AggregatePlaceOrder';
|
|
13
|
-
project: { id: string; typeOf: chevre.factory.organizationType.Project };
|
|
14
|
-
aggregateDate: Date;
|
|
15
|
-
aggregateDuration: string;
|
|
16
|
-
aggregateStart: Date;
|
|
17
|
-
// transactionCount: number;
|
|
18
|
-
// avgDuration: number;
|
|
19
|
-
// maxDuration: number;
|
|
20
|
-
// minDuration: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function main() {
|
|
24
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
25
|
-
|
|
26
|
-
const now: Date = new Date();
|
|
27
|
-
|
|
28
|
-
const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
|
|
29
|
-
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
30
|
-
|
|
31
|
-
let i = 0;
|
|
32
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
33
|
-
while (i < AGGREGATE_DAYS) {
|
|
34
|
-
i += 1;
|
|
35
|
-
|
|
36
|
-
const startFrom: Date = moment()
|
|
37
|
-
// .tz('Asia/Tokyo')
|
|
38
|
-
.add(-i, 'days')
|
|
39
|
-
.startOf('day')
|
|
40
|
-
.toDate();
|
|
41
|
-
const startThrough: Date = moment()
|
|
42
|
-
// .tz('Asia/Tokyo')
|
|
43
|
-
.add(-i, 'days')
|
|
44
|
-
.endOf('day')
|
|
45
|
-
.toDate();
|
|
46
|
-
|
|
47
|
-
const aggregateResult = await transactionRepo.aggregatePlaceOrder({
|
|
48
|
-
project: { id: <any>{ $ne: EXCLUDED_PROJECT_ID } },
|
|
49
|
-
startFrom,
|
|
50
|
-
startThrough,
|
|
51
|
-
typeOf: chevre.factory.transactionType.PlaceOrder
|
|
52
|
-
});
|
|
53
|
-
console.log('aggregateResult', aggregateResult, aggregateResult.statuses[0]?.aggregation.percentilesDuration, startFrom);
|
|
54
|
-
|
|
55
|
-
const aggregation: IAggregation = {
|
|
56
|
-
typeOf: 'AggregatePlaceOrder',
|
|
57
|
-
project: { id: '*', typeOf: chevre.factory.organizationType.Project },
|
|
58
|
-
aggregateDuration: moment.duration(1, 'days')
|
|
59
|
-
.toISOString(),
|
|
60
|
-
aggregateStart: startFrom,
|
|
61
|
-
aggregateDate: now,
|
|
62
|
-
...aggregateResult
|
|
63
|
-
};
|
|
64
|
-
const { typeOf, project, aggregateDuration, aggregateStart, ...setFields } = aggregation;
|
|
65
|
-
const doc = await aggregationRepo.aggregationModel.findOneAndUpdate(
|
|
66
|
-
{
|
|
67
|
-
typeOf: { $eq: aggregation.typeOf },
|
|
68
|
-
'project.id': { $eq: aggregation.project.id },
|
|
69
|
-
aggregateStart: { $eq: aggregation.aggregateStart },
|
|
70
|
-
aggregateDuration: { $eq: aggregation.aggregateDuration }
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
$setOnInsert: {
|
|
74
|
-
typeOf: aggregation.typeOf,
|
|
75
|
-
project: aggregation.project,
|
|
76
|
-
aggregateDuration: aggregation.aggregateDuration,
|
|
77
|
-
aggregateStart: aggregation.aggregateStart
|
|
78
|
-
},
|
|
79
|
-
$set: setFields,
|
|
80
|
-
$unset: {
|
|
81
|
-
avgLargeDuration: 1,
|
|
82
|
-
avgMediumDuration: 1,
|
|
83
|
-
avgSmallDuration: 1,
|
|
84
|
-
stdDevDuration: 1,
|
|
85
|
-
transactionCountByStatus: 1,
|
|
86
|
-
transactionCount: 12,
|
|
87
|
-
avgDuration: 1,
|
|
88
|
-
maxDuration: 1,
|
|
89
|
-
minDuration: 1,
|
|
90
|
-
percentilesDuration: 1
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
{ upsert: true, new: true }
|
|
94
|
-
)
|
|
95
|
-
.exec();
|
|
96
|
-
console.log(doc);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
main()
|
|
101
|
-
.then(() => {
|
|
102
|
-
console.log('success!');
|
|
103
|
-
})
|
|
104
|
-
.catch(console.error);
|