@chevre/domain 20.2.0-alpha.3 → 20.2.0-alpha.30
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/aggregateEventReservation.ts +37 -0
- package/example/src/chevre/aggregation/aggregateSystem.ts +104 -0
- package/example/src/chevre/importEventsFromCOA.ts +8 -1
- package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
- package/example/src/chevre/migrateProjectSubscription.ts +51 -0
- package/example/src/chevre/searchEventIds.ts +24 -0
- package/example/src/chevre/searchEvents.ts +20 -40
- package/lib/chevre/factory/event.d.ts +2 -0
- package/lib/chevre/factory/event.js +2 -0
- package/lib/chevre/repo/action.d.ts +58 -0
- package/lib/chevre/repo/action.js +187 -0
- package/lib/chevre/repo/aggregation.d.ts +36 -0
- package/lib/chevre/repo/aggregation.js +66 -0
- package/lib/chevre/repo/assetTransaction.d.ts +32 -0
- package/lib/chevre/repo/assetTransaction.js +148 -0
- package/lib/chevre/repo/event.d.ts +47 -13
- package/lib/chevre/repo/event.js +386 -113
- package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
- package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
- package/lib/chevre/repo/mongoose/model/event.js +4 -3
- package/lib/chevre/repo/mongoose/model/project.js +7 -1
- package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
- package/lib/chevre/repo/place.d.ts +15 -1
- package/lib/chevre/repo/place.js +175 -10
- package/lib/chevre/repo/product.d.ts +1 -0
- package/lib/chevre/repo/product.js +5 -0
- package/lib/chevre/repo/project.d.ts +4 -1
- package/lib/chevre/repo/project.js +9 -10
- package/lib/chevre/repo/reservation.d.ts +0 -6
- package/lib/chevre/repo/reservation.js +106 -66
- package/lib/chevre/repo/task.d.ts +31 -3
- package/lib/chevre/repo/task.js +141 -27
- package/lib/chevre/repo/transaction.d.ts +35 -0
- package/lib/chevre/repo/transaction.js +163 -0
- package/lib/chevre/repo/trip.js +33 -27
- package/lib/chevre/repository.d.ts +3 -0
- package/lib/chevre/repository.js +5 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +1 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +40 -15
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
- package/lib/chevre/service/aggregation/system.d.ts +86 -0
- package/lib/chevre/service/aggregation/system.js +345 -0
- package/lib/chevre/service/aggregation.d.ts +2 -0
- package/lib/chevre/service/aggregation.js +3 -1
- package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
- package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
- package/lib/chevre/service/assetTransaction/pay.js +65 -32
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
- package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
- package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -2
- package/lib/chevre/service/assetTransaction/reserve.js +43 -56
- package/lib/chevre/service/delivery/factory.js +1 -0
- package/lib/chevre/service/event.d.ts +2 -4
- package/lib/chevre/service/event.js +34 -13
- package/lib/chevre/service/offer/event/authorize.js +5 -1
- package/lib/chevre/service/offer/event/cancel.js +0 -1
- package/lib/chevre/service/offer/event/factory.d.ts +3 -2
- package/lib/chevre/service/offer/event/factory.js +25 -5
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +2 -2
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +124 -9
- package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
- package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
- package/lib/chevre/service/offer.js +36 -20
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +2 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
- package/lib/chevre/service/order/placeOrder.js +16 -0
- package/lib/chevre/service/payment/any.d.ts +5 -0
- package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket.js +8 -2
- package/lib/chevre/service/reserve/confirmReservation.js +7 -10
- package/lib/chevre/service/reserve/useReservation.js +2 -1
- package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
- package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
- package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
- package/lib/chevre/service/task.js +6 -9
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +7 -2
- package/package.json +3 -3
- package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
- package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
import * as redis from 'redis';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: <string>process.env.PROJECT_ID };
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
11
|
+
const client = redis.createClient({
|
|
12
|
+
host: process.env.REDIS_HOST,
|
|
13
|
+
port: Number(process.env.REDIS_PORT),
|
|
14
|
+
password: process.env.REDIS_KEY
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// const now = new Date();
|
|
18
|
+
await chevre.service.aggregation.event.aggregateScreeningEvent({
|
|
19
|
+
id: 'alb35u7m4'
|
|
20
|
+
})({
|
|
21
|
+
event: new chevre.repository.Event(mongoose.connection),
|
|
22
|
+
eventAvailability: new chevre.repository.itemAvailability.ScreeningEvent(client),
|
|
23
|
+
offer: new chevre.repository.Offer(mongoose.connection),
|
|
24
|
+
offerRateLimit: new chevre.repository.rateLimit.Offer(client),
|
|
25
|
+
place: new chevre.repository.Place(mongoose.connection),
|
|
26
|
+
product: new chevre.repository.Product(mongoose.connection),
|
|
27
|
+
project: new chevre.repository.Project(mongoose.connection),
|
|
28
|
+
reservation: new chevre.repository.Reservation(mongoose.connection),
|
|
29
|
+
task: new chevre.repository.Task(mongoose.connection)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
main()
|
|
34
|
+
.then(() => {
|
|
35
|
+
console.log('success!');
|
|
36
|
+
})
|
|
37
|
+
.catch(console.error);
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
const AGGREGATE_CLIENT_IDS = (typeof process.env.AGGREGATE_CLIENT_IDS === 'string') ? process.env.AGGREGATE_CLIENT_IDS.split(',') : [];
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
|
|
15
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
16
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
17
|
+
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
18
|
+
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
19
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
20
|
+
|
|
21
|
+
await aggregationRepo.aggregationModel.deleteMany({
|
|
22
|
+
typeOf: { $in: ['AggregateOrder', 'AggregateReservation'] }
|
|
23
|
+
})
|
|
24
|
+
.exec();
|
|
25
|
+
|
|
26
|
+
await chevre.service.aggregation.system.aggregateEvent({
|
|
27
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
28
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
29
|
+
})({
|
|
30
|
+
agregation: aggregationRepo,
|
|
31
|
+
event: eventRepo
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
await chevre.service.aggregation.system.aggregateTask({
|
|
35
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
36
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
37
|
+
})({
|
|
38
|
+
agregation: aggregationRepo,
|
|
39
|
+
task: taskRepo
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
await chevre.service.aggregation.system.aggregateReserveTransaction({
|
|
43
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
44
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
45
|
+
})({
|
|
46
|
+
agregation: aggregationRepo,
|
|
47
|
+
assetTransaction: assetTransactionRepo
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await chevre.service.aggregation.system.aggregatePayTransaction({
|
|
51
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
52
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
53
|
+
})({
|
|
54
|
+
agregation: aggregationRepo,
|
|
55
|
+
assetTransaction: assetTransactionRepo
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
await chevre.service.aggregation.system.aggregatePlaceOrder({
|
|
59
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
60
|
+
excludedProjectId: EXCLUDED_PROJECT_ID,
|
|
61
|
+
clientIds: AGGREGATE_CLIENT_IDS
|
|
62
|
+
})({
|
|
63
|
+
agregation: aggregationRepo,
|
|
64
|
+
transaction: transactionRepo
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
await chevre.service.aggregation.system.aggregateAuthorizeOrderAction({
|
|
68
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
69
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
70
|
+
})({
|
|
71
|
+
agregation: aggregationRepo,
|
|
72
|
+
action: actionRepo
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await chevre.service.aggregation.system.aggregateAuthorizeEventServiceOfferAction({
|
|
76
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
77
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
78
|
+
})({
|
|
79
|
+
agregation: aggregationRepo,
|
|
80
|
+
action: actionRepo
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
await chevre.service.aggregation.system.aggregateAuthorizePaymentAction({
|
|
84
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
85
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
86
|
+
})({
|
|
87
|
+
agregation: aggregationRepo,
|
|
88
|
+
action: actionRepo
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
await chevre.service.aggregation.system.aggregateUseAction({
|
|
92
|
+
aggregationDays: AGGREGATE_DAYS,
|
|
93
|
+
excludedProjectId: EXCLUDED_PROJECT_ID
|
|
94
|
+
})({
|
|
95
|
+
agregation: aggregationRepo,
|
|
96
|
+
action: actionRepo
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
main()
|
|
101
|
+
.then(() => {
|
|
102
|
+
console.log('success!');
|
|
103
|
+
})
|
|
104
|
+
.catch(console.error);
|
|
@@ -14,6 +14,7 @@ async function main() {
|
|
|
14
14
|
const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
|
|
15
15
|
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
16
16
|
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
17
|
+
const sellerRepo = new chevre.repository.Seller(mongoose.connection);
|
|
17
18
|
|
|
18
19
|
await chevre.service.event.importFromCOA({
|
|
19
20
|
project: {
|
|
@@ -28,7 +29,13 @@ async function main() {
|
|
|
28
29
|
.toDate(),
|
|
29
30
|
saveMovieTheater: false,
|
|
30
31
|
saveScreeningEventSeries: false
|
|
31
|
-
})({
|
|
32
|
+
})({
|
|
33
|
+
action: actionRepo,
|
|
34
|
+
categoryCode: categoryCodeRepo,
|
|
35
|
+
event: eventRepo,
|
|
36
|
+
place: placeRepo,
|
|
37
|
+
seller: sellerRepo
|
|
38
|
+
});
|
|
32
39
|
console.log('imported');
|
|
33
40
|
}
|
|
34
41
|
|
|
@@ -21,7 +21,8 @@ async function main() {
|
|
|
21
21
|
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
22
22
|
startDate: {
|
|
23
23
|
$gte: moment()
|
|
24
|
-
|
|
24
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
25
|
+
.add(-6, 'months')
|
|
25
26
|
.toDate()
|
|
26
27
|
}
|
|
27
28
|
// _id: { $eq: 'al6aff83w' }
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const projectRepo = new chevre.repository.Project(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const cursor = projectRepo.getCursor(
|
|
14
|
+
{
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
// _id: 1,
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
console.log('projects found');
|
|
21
|
+
|
|
22
|
+
let i = 0;
|
|
23
|
+
let updateCount = 0;
|
|
24
|
+
// tslint:disable-next-line:max-func-body-length
|
|
25
|
+
await cursor.eachAsync(async (doc) => {
|
|
26
|
+
i += 1;
|
|
27
|
+
const project: chevre.factory.project.IProject = doc.toObject();
|
|
28
|
+
|
|
29
|
+
const useEventServiceAsProduct = project.subscription?.useEventServiceAsProduct;
|
|
30
|
+
const alreadyMigrated = useEventServiceAsProduct === true;
|
|
31
|
+
|
|
32
|
+
if (alreadyMigrated) {
|
|
33
|
+
console.log('already migrated.', project.id, i);
|
|
34
|
+
} else {
|
|
35
|
+
console.log(
|
|
36
|
+
'updating product...', project.id, i);
|
|
37
|
+
await projectRepo.findByIdAndIUpdate({
|
|
38
|
+
id: project.id,
|
|
39
|
+
subscription: { useEventServiceAsProduct: true }
|
|
40
|
+
});
|
|
41
|
+
updateCount += 1;
|
|
42
|
+
console.log('updated...', project.id, i);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
console.log(i, 'projects checked');
|
|
46
|
+
console.log(updateCount, 'projects updated');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
main()
|
|
50
|
+
.then()
|
|
51
|
+
.catch(console.error);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const ids = await eventRepo.searchIds({
|
|
14
|
+
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
15
|
+
project: { id: { $eq: PROJECT_ID } },
|
|
16
|
+
id: { $in: ['al6afe7ad', 'al6afe7ae'] }
|
|
17
|
+
});
|
|
18
|
+
console.log(ids);
|
|
19
|
+
console.log(ids.length);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
main()
|
|
23
|
+
.then(console.log)
|
|
24
|
+
.catch(console.error);
|
|
@@ -11,47 +11,27 @@ async function main() {
|
|
|
11
11
|
|
|
12
12
|
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
availabilityStarts: {
|
|
32
|
-
$gte: moment('2022-11-15T15:00:00.000Z')
|
|
33
|
-
.toDate(),
|
|
34
|
-
$lte: moment('2022-11-15T15:00:00.000Z')
|
|
35
|
-
.toDate()
|
|
36
|
-
},
|
|
37
|
-
validFrom: {
|
|
38
|
-
$gte: moment('2022-11-15T15:00:00.000Z')
|
|
39
|
-
.toDate(),
|
|
40
|
-
$lte: moment('2022-11-15T15:00:00.000Z')
|
|
41
|
-
.toDate()
|
|
42
|
-
},
|
|
43
|
-
validThrough: {
|
|
44
|
-
$gte: moment('2022-11-18T02:20:00.000Z')
|
|
45
|
-
.toDate(),
|
|
46
|
-
$lte: moment('2022-11-18T02:20:00.000Z')
|
|
47
|
-
.toDate()
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
14
|
+
const event = await eventRepo.findById(
|
|
15
|
+
{ id: 'al6aff83y' },
|
|
16
|
+
{
|
|
17
|
+
name: 1
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
console.log('event found', event);
|
|
21
|
+
|
|
22
|
+
const events = await eventRepo.search(
|
|
23
|
+
{
|
|
24
|
+
limit: 100,
|
|
25
|
+
page: 1,
|
|
26
|
+
sort: { startDate: 1 },
|
|
27
|
+
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
28
|
+
project: { id: { $eq: PROJECT_ID } },
|
|
29
|
+
id: { $in: ['al6aff83y'] }
|
|
52
30
|
},
|
|
53
|
-
|
|
54
|
-
|
|
31
|
+
{
|
|
32
|
+
name: 1
|
|
33
|
+
}
|
|
34
|
+
);
|
|
55
35
|
console.log(events);
|
|
56
36
|
console.log(events.length);
|
|
57
37
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import * as factory from '../factory';
|
|
2
|
+
export declare type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers'> : never;
|
|
@@ -7,6 +7,23 @@ export interface IUseActionCountByOffer {
|
|
|
7
7
|
_id: string[];
|
|
8
8
|
useActionCount?: number;
|
|
9
9
|
}
|
|
10
|
+
interface IAggregationByStatus {
|
|
11
|
+
actionCount: number;
|
|
12
|
+
avgDuration: number;
|
|
13
|
+
maxDuration: number;
|
|
14
|
+
minDuration: number;
|
|
15
|
+
percentilesDuration: {
|
|
16
|
+
name: string;
|
|
17
|
+
value: number;
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
interface IStatus {
|
|
21
|
+
status: factory.actionStatusType;
|
|
22
|
+
aggregation: IAggregationByStatus;
|
|
23
|
+
}
|
|
24
|
+
interface IAggregateAction {
|
|
25
|
+
statuses: IStatus[];
|
|
26
|
+
}
|
|
10
27
|
export { modelName };
|
|
11
28
|
/**
|
|
12
29
|
* アクションリポジトリ
|
|
@@ -107,4 +124,45 @@ export declare class MongoRepository {
|
|
|
107
124
|
deleteEndDatePassedCertainPeriod(params: {
|
|
108
125
|
$lt: Date;
|
|
109
126
|
}): Promise<void>;
|
|
127
|
+
aggregateAuthorizeEventServiceOfferAction(params: {
|
|
128
|
+
project?: {
|
|
129
|
+
id?: {
|
|
130
|
+
$ne?: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
startFrom: Date;
|
|
134
|
+
startThrough: Date;
|
|
135
|
+
typeOf: factory.actionType;
|
|
136
|
+
}): Promise<IAggregateAction>;
|
|
137
|
+
aggregateAuthorizePaymentAction(params: {
|
|
138
|
+
project?: {
|
|
139
|
+
id?: {
|
|
140
|
+
$ne?: string;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
startFrom: Date;
|
|
144
|
+
startThrough: Date;
|
|
145
|
+
typeOf: factory.actionType;
|
|
146
|
+
}): Promise<IAggregateAction>;
|
|
147
|
+
aggregateAuthorizeOrderAction(params: {
|
|
148
|
+
project?: {
|
|
149
|
+
id?: {
|
|
150
|
+
$ne?: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
startFrom: Date;
|
|
154
|
+
startThrough: Date;
|
|
155
|
+
typeOf: factory.actionType;
|
|
156
|
+
}): Promise<IAggregateAction>;
|
|
157
|
+
aggregateUseAction(params: {
|
|
158
|
+
project?: {
|
|
159
|
+
id?: {
|
|
160
|
+
$ne?: string;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
startFrom: Date;
|
|
164
|
+
startThrough: Date;
|
|
165
|
+
typeOf: factory.actionType;
|
|
166
|
+
}): Promise<IAggregateAction>;
|
|
167
|
+
private agggregateByStatus;
|
|
110
168
|
}
|
|
@@ -677,5 +677,192 @@ class MongoRepository {
|
|
|
677
677
|
.exec();
|
|
678
678
|
});
|
|
679
679
|
}
|
|
680
|
+
aggregateAuthorizeEventServiceOfferAction(params) {
|
|
681
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
682
|
+
const statuses = yield Promise.all([
|
|
683
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
684
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
685
|
+
factory.actionStatusType.FailedActionStatus
|
|
686
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
687
|
+
var _a, _b;
|
|
688
|
+
const matchConditions = Object.assign({ startDate: {
|
|
689
|
+
$gte: params.startFrom,
|
|
690
|
+
$lte: params.startThrough
|
|
691
|
+
}, typeOf: { $eq: params.typeOf }, actionStatus: { $eq: actionStatus }, 'object.typeOf': {
|
|
692
|
+
$exists: true,
|
|
693
|
+
$eq: factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation
|
|
694
|
+
} }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
695
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
696
|
+
: undefined);
|
|
697
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
698
|
+
})));
|
|
699
|
+
return { statuses };
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
aggregateAuthorizePaymentAction(params) {
|
|
703
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
704
|
+
const statuses = yield Promise.all([
|
|
705
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
706
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
707
|
+
factory.actionStatusType.FailedActionStatus
|
|
708
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
709
|
+
var _a, _b;
|
|
710
|
+
const matchConditions = Object.assign({ startDate: {
|
|
711
|
+
$gte: params.startFrom,
|
|
712
|
+
$lte: params.startThrough
|
|
713
|
+
}, typeOf: { $eq: params.typeOf }, actionStatus: { $eq: actionStatus }, 'object.typeOf': {
|
|
714
|
+
$exists: true,
|
|
715
|
+
$eq: factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
716
|
+
} }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
717
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
718
|
+
: undefined);
|
|
719
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
720
|
+
})));
|
|
721
|
+
return { statuses };
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
aggregateAuthorizeOrderAction(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 }, 'object.typeOf': {
|
|
736
|
+
$exists: true,
|
|
737
|
+
$eq: factory.order.OrderType.Order
|
|
738
|
+
} }, (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$ne) === 'string')
|
|
739
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
740
|
+
: undefined);
|
|
741
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
742
|
+
})));
|
|
743
|
+
return { statuses };
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
aggregateUseAction(params) {
|
|
747
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
748
|
+
const statuses = yield Promise.all([
|
|
749
|
+
factory.actionStatusType.CompletedActionStatus,
|
|
750
|
+
factory.actionStatusType.CanceledActionStatus,
|
|
751
|
+
factory.actionStatusType.FailedActionStatus
|
|
752
|
+
].map((actionStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
753
|
+
var _a, _b;
|
|
754
|
+
const matchConditions = Object.assign({ startDate: {
|
|
755
|
+
$gte: params.startFrom,
|
|
756
|
+
$lte: params.startThrough
|
|
757
|
+
}, 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')
|
|
758
|
+
? { 'project.id': { $ne: params.project.id.$ne } }
|
|
759
|
+
: undefined);
|
|
760
|
+
return this.agggregateByStatus({ matchConditions, actionStatus });
|
|
761
|
+
})));
|
|
762
|
+
return { statuses };
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
// tslint:disable-next-line:max-func-body-length
|
|
766
|
+
agggregateByStatus(params) {
|
|
767
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
768
|
+
const aggregations = yield this.actionModel.aggregate([
|
|
769
|
+
{ $match: params.matchConditions },
|
|
770
|
+
{
|
|
771
|
+
$project: {
|
|
772
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
773
|
+
actionStatus: '$actionStatus',
|
|
774
|
+
startDate: '$startDate',
|
|
775
|
+
endDate: '$endDate',
|
|
776
|
+
typeOf: '$typeOf'
|
|
777
|
+
}
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
$group: {
|
|
781
|
+
_id: '$typeOf',
|
|
782
|
+
actionCount: { $sum: 1 },
|
|
783
|
+
maxDuration: { $max: '$duration' },
|
|
784
|
+
minDuration: { $min: '$duration' },
|
|
785
|
+
avgDuration: { $avg: '$duration' }
|
|
786
|
+
}
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
$project: {
|
|
790
|
+
_id: 0,
|
|
791
|
+
actionCount: '$actionCount',
|
|
792
|
+
avgDuration: '$avgDuration',
|
|
793
|
+
maxDuration: '$maxDuration',
|
|
794
|
+
minDuration: '$minDuration'
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
])
|
|
798
|
+
.exec();
|
|
799
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
800
|
+
const percents = [50, 95, 99];
|
|
801
|
+
if (aggregations.length === 0) {
|
|
802
|
+
return {
|
|
803
|
+
status: params.actionStatus,
|
|
804
|
+
aggregation: {
|
|
805
|
+
actionCount: 0,
|
|
806
|
+
avgDuration: 0,
|
|
807
|
+
maxDuration: 0,
|
|
808
|
+
minDuration: 0,
|
|
809
|
+
percentilesDuration: percents.map((percent) => {
|
|
810
|
+
return {
|
|
811
|
+
name: String(percent),
|
|
812
|
+
value: 0
|
|
813
|
+
};
|
|
814
|
+
})
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
const ranks4percentile = percents.map((percentile) => {
|
|
819
|
+
return {
|
|
820
|
+
percentile,
|
|
821
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
822
|
+
rank: Math.floor(aggregations[0].actionCount * percentile / 100)
|
|
823
|
+
};
|
|
824
|
+
});
|
|
825
|
+
const aggregations2 = yield this.actionModel.aggregate([
|
|
826
|
+
{
|
|
827
|
+
$match: params.matchConditions
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
$project: {
|
|
831
|
+
duration: { $subtract: ['$endDate', '$startDate'] },
|
|
832
|
+
actionStatus: '$actionStatus',
|
|
833
|
+
startDate: '$startDate',
|
|
834
|
+
endDate: '$endDate',
|
|
835
|
+
typeOf: '$typeOf'
|
|
836
|
+
}
|
|
837
|
+
},
|
|
838
|
+
{ $sort: { duration: 1 } },
|
|
839
|
+
{
|
|
840
|
+
$group: {
|
|
841
|
+
_id: '$typeOf',
|
|
842
|
+
durations: { $push: '$duration' }
|
|
843
|
+
}
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
$project: {
|
|
847
|
+
_id: 0,
|
|
848
|
+
avgSmallDuration: '$avgSmallDuration',
|
|
849
|
+
avgMediumDuration: '$avgMediumDuration',
|
|
850
|
+
avgLargeDuration: '$avgLargeDuration',
|
|
851
|
+
percentilesDuration: ranks4percentile.map((rank) => {
|
|
852
|
+
return {
|
|
853
|
+
name: String(rank.percentile),
|
|
854
|
+
value: { $arrayElemAt: ['$durations', rank.rank] }
|
|
855
|
+
};
|
|
856
|
+
})
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
])
|
|
860
|
+
.exec();
|
|
861
|
+
return {
|
|
862
|
+
status: params.actionStatus,
|
|
863
|
+
aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
|
|
864
|
+
};
|
|
865
|
+
});
|
|
866
|
+
}
|
|
680
867
|
}
|
|
681
868
|
exports.MongoRepository = MongoRepository;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Connection, Model } from 'mongoose';
|
|
2
|
+
import * as factory from '../factory';
|
|
3
|
+
export declare enum AggregationType {
|
|
4
|
+
AggregateAuthorizeEventServiceOfferAction = "AggregateAuthorizeEventServiceOfferAction",
|
|
5
|
+
AggregateAuthorizeOrderAction = "AggregateAuthorizeOrderAction",
|
|
6
|
+
AggregateAuthorizePaymentAction = "AggregateAuthorizePaymentAction",
|
|
7
|
+
AggregateEvent = "AggregateEvent",
|
|
8
|
+
AggregatePay = "AggregatePay",
|
|
9
|
+
AggregatePlaceOrder = "AggregatePlaceOrder",
|
|
10
|
+
AggregateReserve = "AggregateReserve",
|
|
11
|
+
AggregateTask = "AggregateTask",
|
|
12
|
+
AggregateUseAction = "AggregateUseAction"
|
|
13
|
+
}
|
|
14
|
+
export interface IAggregationByClient {
|
|
15
|
+
clientId: string;
|
|
16
|
+
aggregation: any;
|
|
17
|
+
}
|
|
18
|
+
export interface IAggregation {
|
|
19
|
+
typeOf: AggregationType;
|
|
20
|
+
project: {
|
|
21
|
+
id: string;
|
|
22
|
+
typeOf: factory.organizationType.Project;
|
|
23
|
+
};
|
|
24
|
+
aggregateDate: Date;
|
|
25
|
+
aggregateDuration: string;
|
|
26
|
+
aggregateStart: Date;
|
|
27
|
+
aggregationByClient?: IAggregationByClient[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 集計リポジトリ
|
|
31
|
+
*/
|
|
32
|
+
export declare class MongoRepository {
|
|
33
|
+
readonly aggregationModel: typeof Model;
|
|
34
|
+
constructor(connection: Connection);
|
|
35
|
+
saveAggregation(params: IAggregation): Promise<any>;
|
|
36
|
+
}
|