@chevre/domain 22.11.0 → 22.12.0-alpha.0
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/aggregateOrderOfCustomer.ts +5 -2
- package/example/src/chevre/aggregation/aggregateOrderOfCustomerGlobally.ts +34 -0
- package/example/src/chevre/reIndex.ts +1 -1
- package/lib/chevre/factory/event.d.ts +1 -1
- package/lib/chevre/repo/event.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/aggregateOrder.js +9 -0
- package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
- package/lib/chevre/repo/order.d.ts +7 -1
- package/lib/chevre/repo/order.js +25 -2
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +7 -4
- package/lib/chevre/service/assetTransaction/reserve/start.js +5 -1
- package/package.json +3 -3
|
@@ -7,6 +7,9 @@ import { chevre } from '../../../../lib/index';
|
|
|
7
7
|
|
|
8
8
|
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
9
9
|
const AGGREGATE_PERIOD_IN_DAYS = 365;
|
|
10
|
+
const AGGREGATE_ORDER_CLIENT_IDS = (typeof process.env.AGGREGATE_ORDER_CLIENT_IDS === 'string')
|
|
11
|
+
? process.env.AGGREGATE_ORDER_CLIENT_IDS.split(' ')
|
|
12
|
+
: [];
|
|
10
13
|
|
|
11
14
|
function createAggregation(params: {
|
|
12
15
|
order: Pick<chevre.factory.order.IOrder, 'customer' | 'orderDate' | 'orderNumber' | 'project'>;
|
|
@@ -35,7 +38,7 @@ function createAggregation(params: {
|
|
|
35
38
|
|
|
36
39
|
// tslint:disable-next-line:max-func-body-length
|
|
37
40
|
async function main() {
|
|
38
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
41
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false, appName: 'sample' });
|
|
39
42
|
|
|
40
43
|
const aggregateOrderRepo = await chevre.repository.AggregateOrder.createInstance(mongoose.connection);
|
|
41
44
|
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
@@ -56,7 +59,7 @@ async function main() {
|
|
|
56
59
|
typeOf: { $eq: chevre.factory.order.OrderType.Order },
|
|
57
60
|
'customer.id': { // exclude pos,tvm
|
|
58
61
|
$exists: true,
|
|
59
|
-
$in:
|
|
62
|
+
$in: AGGREGATE_ORDER_CLIENT_IDS
|
|
60
63
|
}
|
|
61
64
|
},
|
|
62
65
|
{
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as fs from 'fs';
|
|
3
|
+
import * as moment from 'moment-timezone';
|
|
4
|
+
import * as mongoose from 'mongoose';
|
|
5
|
+
|
|
6
|
+
import { chevre } from '../../../../lib/index';
|
|
7
|
+
|
|
8
|
+
const AGGREGATE_PERIOD_IN_DAYS = 365;
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false, appName: 'sample' });
|
|
13
|
+
|
|
14
|
+
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const orderDateLte: Date = moment()
|
|
17
|
+
.toDate();
|
|
18
|
+
const orderDateGte: Date = moment(orderDateLte)
|
|
19
|
+
.add(-AGGREGATE_PERIOD_IN_DAYS, 'days')
|
|
20
|
+
.toDate();
|
|
21
|
+
|
|
22
|
+
console.log('aggregating...');
|
|
23
|
+
const result = await orderRepo.aggregateOrderOfCustomerGlobally({
|
|
24
|
+
orderDate: { $gte: orderDateGte, $lte: orderDateLte },
|
|
25
|
+
customer: { email: { $eq: 'ilovegadd@gmail.com' } }
|
|
26
|
+
});
|
|
27
|
+
console.log(result);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main()
|
|
31
|
+
.then(() => {
|
|
32
|
+
console.log('success!');
|
|
33
|
+
})
|
|
34
|
+
.catch(console.error);
|
|
@@ -11,7 +11,7 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
|
-
await chevre.repository.
|
|
14
|
+
await chevre.repository.AggregateOrder.createInstance(mongoose.connection);
|
|
15
15
|
console.log('success!');
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as factory from '../factory';
|
|
2
|
-
export type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers'> & {
|
|
2
|
+
export type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier' | 'maximumPhysicalAttendeeCapacity'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers' | 'maximumPhysicalAttendeeCapacity'> & {
|
|
3
3
|
superEvent?: never;
|
|
4
4
|
} : never;
|
|
5
5
|
/**
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -32,7 +32,7 @@ const AVAILABLE_PUBLIC_PROJECT_FIELDS = [
|
|
|
32
32
|
'doorTime', 'endDate', 'eventStatus', 'identifier', 'location',
|
|
33
33
|
'maximumAttendeeCapacity', 'name',
|
|
34
34
|
// 'offers',
|
|
35
|
-
'organizer', 'project', 'remainingAttendeeCapacity', 'startDate', 'superEvent', 'typeOf'
|
|
35
|
+
'organizer', 'project', 'remainingAttendeeCapacity', 'startDate', 'superEvent', 'typeOf', 'maximumPhysicalAttendeeCapacity'
|
|
36
36
|
];
|
|
37
37
|
/**
|
|
38
38
|
* イベントリポジトリ
|
|
@@ -61,6 +61,15 @@ const indexes = [
|
|
|
61
61
|
[
|
|
62
62
|
{ typeOf: 1, identifier: 1 },
|
|
63
63
|
{ name: 'typeOf' }
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
{ 'aggregateOrder.aggregateProject.projectCount': 1, identifier: 1 },
|
|
67
|
+
{
|
|
68
|
+
name: 'aggregateProjectProjectCount',
|
|
69
|
+
partialFilterExpression: {
|
|
70
|
+
'aggregateOrder.aggregateProject.projectCount': { $exists: true }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
64
73
|
]
|
|
65
74
|
];
|
|
66
75
|
exports.indexes = indexes;
|
|
@@ -33,6 +33,7 @@ const schemaDefinition = {
|
|
|
33
33
|
superEvent: mongoose_1.SchemaTypes.Mixed,
|
|
34
34
|
offers: mongoose_1.SchemaTypes.Mixed,
|
|
35
35
|
maximumAttendeeCapacity: { type: Number },
|
|
36
|
+
maximumPhysicalAttendeeCapacity: { type: Number, required: false }, // add(2025-08-24~)
|
|
36
37
|
remainingAttendeeCapacity: { type: Number },
|
|
37
38
|
checkInCount: { type: Number },
|
|
38
39
|
attendeeCount: { type: Number },
|
|
@@ -16,6 +16,12 @@ interface IAggregation {
|
|
|
16
16
|
maxPrice: number;
|
|
17
17
|
minPrice: number;
|
|
18
18
|
}
|
|
19
|
+
interface IGlobalAggregateOrder {
|
|
20
|
+
orderCount: number;
|
|
21
|
+
aggregateProject: {
|
|
22
|
+
projectCount: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
19
25
|
interface IAggregateOrder {
|
|
20
26
|
aggregation: IAggregation;
|
|
21
27
|
}
|
|
@@ -236,7 +242,7 @@ export declare class OrderRepo {
|
|
|
236
242
|
};
|
|
237
243
|
};
|
|
238
244
|
}): Promise<{
|
|
239
|
-
aggregation:
|
|
245
|
+
aggregation: IGlobalAggregateOrder & {
|
|
240
246
|
sumGraceTime?: never;
|
|
241
247
|
};
|
|
242
248
|
}>;
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -1280,12 +1280,35 @@ class OrderRepo {
|
|
|
1280
1280
|
if (aggregations.length === 0) {
|
|
1281
1281
|
return {
|
|
1282
1282
|
aggregation: {
|
|
1283
|
-
orderCount: 0
|
|
1283
|
+
orderCount: 0,
|
|
1284
|
+
aggregateProject: { projectCount: 0 }
|
|
1284
1285
|
}
|
|
1285
1286
|
};
|
|
1286
1287
|
}
|
|
1288
|
+
const aggregations2 = yield this.orderModel.aggregate([
|
|
1289
|
+
{ $match: matchConditions },
|
|
1290
|
+
{
|
|
1291
|
+
$project: {
|
|
1292
|
+
project: '$project'
|
|
1293
|
+
}
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
$group: {
|
|
1297
|
+
_id: '$project.id'
|
|
1298
|
+
}
|
|
1299
|
+
},
|
|
1300
|
+
{
|
|
1301
|
+
$count: 'projectCount'
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
$project: {
|
|
1305
|
+
aggregateProject: { projectCount: '$projectCount' }
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
])
|
|
1309
|
+
.exec();
|
|
1287
1310
|
return {
|
|
1288
|
-
aggregation: Object.assign({}, aggregations[0])
|
|
1311
|
+
aggregation: Object.assign(Object.assign({}, aggregations[0]), aggregations2[0])
|
|
1289
1312
|
};
|
|
1290
1313
|
});
|
|
1291
1314
|
}
|
|
@@ -28,7 +28,7 @@ function aggregateScreeningEvent(params) {
|
|
|
28
28
|
) => __awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
var _a, _b, _c, _d;
|
|
30
30
|
// 集計対象イベント検索
|
|
31
|
-
const event = yield repos.event.projectEventFieldsById({ id: params.id }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.id', 'superEvent.location.id', 'offers.itemOffered']);
|
|
31
|
+
const event = yield repos.event.projectEventFieldsById({ id: params.id }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.id', 'superEvent.location.id', 'offers.itemOffered', 'maximumPhysicalAttendeeCapacity']);
|
|
32
32
|
// プロジェクト設定検索
|
|
33
33
|
const project = yield repos.project.findById({
|
|
34
34
|
id: event.project.id,
|
|
@@ -66,7 +66,7 @@ function aggregateScreeningEvent(params) {
|
|
|
66
66
|
startFrom: startFrom,
|
|
67
67
|
startThrough: startThrough,
|
|
68
68
|
location: { branchCode: { $eq: event.location.branchCode } }
|
|
69
|
-
}, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered']);
|
|
69
|
+
}, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered', 'maximumPhysicalAttendeeCapacity']);
|
|
70
70
|
}
|
|
71
71
|
else if (event.typeOf === factory.eventType.ScreeningEvent) {
|
|
72
72
|
aggregatingEvents = yield repos.event.projectEventFields({
|
|
@@ -78,7 +78,7 @@ function aggregateScreeningEvent(params) {
|
|
|
78
78
|
startFrom: startFrom,
|
|
79
79
|
startThrough: startThrough,
|
|
80
80
|
location: { branchCode: { $eq: event.location.branchCode } }
|
|
81
|
-
}, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered']);
|
|
81
|
+
}, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered', 'maximumPhysicalAttendeeCapacity']);
|
|
82
82
|
}
|
|
83
83
|
// ID指定されたイベントについてはEventScheduledでなくても集計したいので、集計対象を調整
|
|
84
84
|
aggregatingEvents = aggregatingEvents.filter((e) => e.id !== event.id);
|
|
@@ -234,7 +234,10 @@ function aggregateReservationByEvent(params) {
|
|
|
234
234
|
reservationStatuses: [factory.reservationStatusType.ReservationConfirmed]
|
|
235
235
|
});
|
|
236
236
|
// maximumAttendeeCapacityを決定
|
|
237
|
-
|
|
237
|
+
let eventLocationMaximumAttendeeCapacity = params.event.location.maximumAttendeeCapacity;
|
|
238
|
+
if (typeof params.event.maximumPhysicalAttendeeCapacity === 'number') {
|
|
239
|
+
eventLocationMaximumAttendeeCapacity = params.event.maximumPhysicalAttendeeCapacity;
|
|
240
|
+
}
|
|
238
241
|
if (typeof eventLocationMaximumAttendeeCapacity === 'number') {
|
|
239
242
|
maximumAttendeeCapacity = eventLocationMaximumAttendeeCapacity;
|
|
240
243
|
}
|
|
@@ -100,7 +100,7 @@ function fixEvent(params) {
|
|
|
100
100
|
// additionalProperty, // discontinue(2024-07-20~)
|
|
101
101
|
'name', 'doorTime', 'endDate', 'eventStatus',
|
|
102
102
|
'location', 'startDate', 'superEvent',
|
|
103
|
-
'offers'
|
|
103
|
+
'offers', 'maximumPhysicalAttendeeCapacity'
|
|
104
104
|
// 'coaInfo', // discontinue(2024-07-24~)
|
|
105
105
|
// 'identifier' // discontinue(2024-07-24~)
|
|
106
106
|
]);
|
|
@@ -504,6 +504,7 @@ function processLockOfferRateLimit(params) {
|
|
|
504
504
|
/**
|
|
505
505
|
* 座席ロックプロセス
|
|
506
506
|
*/
|
|
507
|
+
// tslint:disable-next-line:max-func-body-length
|
|
507
508
|
function processLockSeats(params) {
|
|
508
509
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
509
510
|
var _a, _b, _c, _d, _e;
|
|
@@ -554,6 +555,9 @@ function processLockSeats(params) {
|
|
|
554
555
|
const bookingTime = params.transaction.startDate; // fix as transactionNumber(2024-07-02~)
|
|
555
556
|
const hasTicketedSeat = ((_d = (_c = (_b = params.event.offers.itemOffered.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservedTicket) === null || _c === void 0 ? void 0 : _c.ticketedSeat) === null || _d === void 0 ? void 0 : _d.typeOf) === factory.placeType.Seat;
|
|
556
557
|
let maximumAttendeeCapacity4event = (_e = params.event.location) === null || _e === void 0 ? void 0 : _e.maximumAttendeeCapacity;
|
|
558
|
+
if (typeof params.event.maximumPhysicalAttendeeCapacity === 'number') {
|
|
559
|
+
maximumAttendeeCapacity4event = params.event.maximumPhysicalAttendeeCapacity;
|
|
560
|
+
}
|
|
557
561
|
// 座席無の場合デフォルトmaximumAttendeeCapacityを適用(2025-04-20~)
|
|
558
562
|
if (!hasTicketedSeat) {
|
|
559
563
|
if (typeof maximumAttendeeCapacity4event !== 'number') {
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.
|
|
15
|
-
"@cinerino/sdk": "12.0.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.397.0-alpha.0",
|
|
15
|
+
"@cinerino/sdk": "12.0.0-alpha.1",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.0",
|
|
18
18
|
"@sendgrid/client": "8.1.4",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "22.
|
|
118
|
+
"version": "22.12.0-alpha.0"
|
|
119
119
|
}
|