@chevre/domain 22.9.0-alpha.104 → 22.9.0-alpha.105
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/stockHolder/getSize.ts +0 -17
- package/example/src/chevre/stockHolder/searchSeats.ts +75 -0
- package/lib/chevre/repo/place/seat.d.ts +1 -0
- package/lib/chevre/repo/place/seat.js +189 -6
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
- package/package.json +1 -1
|
@@ -55,23 +55,6 @@ async function main() {
|
|
|
55
55
|
});
|
|
56
56
|
console.log('countUnavailableOffersResult:', result);
|
|
57
57
|
|
|
58
|
-
startTime = process.hrtime();
|
|
59
|
-
result = await pendingReservationRepo.countUnavailableOffersByNumSeats(
|
|
60
|
-
{
|
|
61
|
-
event: {
|
|
62
|
-
id: eventId,
|
|
63
|
-
startDate: eventStartDate,
|
|
64
|
-
hasTicketedSeat: true
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
limit: 100
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
diff = process.hrtime(startTime);
|
|
72
|
-
console.log('countUnavailableOffersByNumSeatsResult:', result);
|
|
73
|
-
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
74
|
-
|
|
75
58
|
startTime = process.hrtime();
|
|
76
59
|
const searchHoldersResult = await pendingReservationRepo.searchHolders({
|
|
77
60
|
project: { id: project.id },
|
|
@@ -0,0 +1,75 @@
|
|
|
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 SCREEN_CODE = '10';
|
|
8
|
+
const MOVIE_THEATER_CODE = '118';
|
|
9
|
+
|
|
10
|
+
const formatter = new Intl.NumberFormat('ja-JP');
|
|
11
|
+
|
|
12
|
+
// tslint:disable-next-line:max-func-body-length
|
|
13
|
+
async function main() {
|
|
14
|
+
let startTime: [number, number] = process.hrtime();
|
|
15
|
+
let diff: [number, number] = process.hrtime(startTime);
|
|
16
|
+
|
|
17
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
18
|
+
|
|
19
|
+
const seatRepo = await chevre.repository.place.Seat.createInstance(mongoose.connection);
|
|
20
|
+
|
|
21
|
+
startTime = process.hrtime();
|
|
22
|
+
const seats = <Pick<chevre.factory.place.seat.IPlace, 'branchCode'>[]>await seatRepo.searchSeats({
|
|
23
|
+
limit: 100,
|
|
24
|
+
page: 4,
|
|
25
|
+
$projection: {
|
|
26
|
+
'containedInPlace.containedInPlace': 0,
|
|
27
|
+
'containedInPlace.typeOf': 0,
|
|
28
|
+
'containedInPlace.name': 0,
|
|
29
|
+
typeOf: 0,
|
|
30
|
+
additionalProperty: 0
|
|
31
|
+
},
|
|
32
|
+
project: { id: { $eq: PROJECT_ID } },
|
|
33
|
+
containedInPlace: {
|
|
34
|
+
containedInPlace: {
|
|
35
|
+
branchCode: { $eq: SCREEN_CODE },
|
|
36
|
+
containedInPlace: { branchCode: { $eq: MOVIE_THEATER_CODE } }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
diff = process.hrtime(startTime);
|
|
41
|
+
console.log(seats);
|
|
42
|
+
console.log(seats.length, 'seats found');
|
|
43
|
+
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
44
|
+
|
|
45
|
+
// startTime = process.hrtime();
|
|
46
|
+
// seats = <Pick<chevre.factory.place.seat.IPlace, 'branchCode'>[]>await seatRepo.searchSeats(
|
|
47
|
+
// {
|
|
48
|
+
// limit: 100,
|
|
49
|
+
// page: 1,
|
|
50
|
+
// $projection: {
|
|
51
|
+
// 'containedInPlace.containedInPlace': 0,
|
|
52
|
+
// 'containedInPlace.typeOf': 0,
|
|
53
|
+
// 'containedInPlace.name': 0,
|
|
54
|
+
// typeOf: 0,
|
|
55
|
+
// additionalProperty: 0
|
|
56
|
+
// },
|
|
57
|
+
// project: { id: { $eq: PROJECT_ID } },
|
|
58
|
+
// containedInPlace: {
|
|
59
|
+
// containedInPlace: {
|
|
60
|
+
// branchCode: { $eq: SCREEN_CODE },
|
|
61
|
+
// containedInPlace: { branchCode: { $eq: MOVIE_THEATER_CODE } }
|
|
62
|
+
// }
|
|
63
|
+
// }
|
|
64
|
+
// }
|
|
65
|
+
// );
|
|
66
|
+
// diff = process.hrtime(startTime);
|
|
67
|
+
// console.log(seats.length, 'seats found');
|
|
68
|
+
// console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
main()
|
|
72
|
+
.then(() => {
|
|
73
|
+
console.log('success!');
|
|
74
|
+
})
|
|
75
|
+
.catch(console.error);
|
|
@@ -9,11 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SeatRepo = void 0;
|
|
12
|
+
exports.SeatRepo = exports.DEFAULT_ROOM_MAXIMUM_CAPACITY = void 0;
|
|
13
13
|
const factory = require("../../factory");
|
|
14
14
|
const settings_1 = require("../../settings");
|
|
15
15
|
const civicStructure_1 = require("../mongoose/schemas/civicStructure");
|
|
16
16
|
const place_1 = require("../mongoose/schemas/place");
|
|
17
|
+
exports.DEFAULT_ROOM_MAXIMUM_CAPACITY = 10000;
|
|
17
18
|
/**
|
|
18
19
|
* 座席リポジトリ
|
|
19
20
|
*/
|
|
@@ -328,21 +329,203 @@ class SeatRepo {
|
|
|
328
329
|
}
|
|
329
330
|
const projectStage = SeatRepo.CREATE_SEARCH_SEATS_PROJECTION(Object.assign({}, params.$projection));
|
|
330
331
|
const aggregate = this.placeModel.aggregate([
|
|
331
|
-
{
|
|
332
|
-
|
|
332
|
+
{
|
|
333
|
+
$unwind: {
|
|
334
|
+
path: '$containsPlace',
|
|
335
|
+
includeArrayIndex: 'sectionIndex'
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
$unwind: {
|
|
340
|
+
path: '$containsPlace.containsPlace',
|
|
341
|
+
includeArrayIndex: 'seatIndex'
|
|
342
|
+
}
|
|
343
|
+
},
|
|
333
344
|
...matchStages,
|
|
334
|
-
{
|
|
345
|
+
{
|
|
346
|
+
$project: Object.assign(Object.assign({}, projectStage), {
|
|
347
|
+
// sectionIndex: '$sectionIndex',
|
|
348
|
+
// seatIndex: '$seatIndex',
|
|
349
|
+
// add combinedIndex(2025-04-27~)
|
|
350
|
+
combinedIndex: {
|
|
351
|
+
$add: [
|
|
352
|
+
{ $multiply: ['$sectionIndex', exports.DEFAULT_ROOM_MAXIMUM_CAPACITY] },
|
|
353
|
+
'$seatIndex'
|
|
354
|
+
]
|
|
355
|
+
} })
|
|
356
|
+
}
|
|
335
357
|
]);
|
|
336
358
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
337
359
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
338
|
-
|
|
339
|
-
|
|
360
|
+
// reimplement using $sort + $skip + $limit(2025-4-27~)
|
|
361
|
+
// aggregate.limit(params.limit * page)
|
|
362
|
+
// .skip(params.limit * (page - 1));
|
|
363
|
+
aggregate
|
|
364
|
+
.sort({ combinedIndex: factory.sortType.Ascending })
|
|
365
|
+
.skip(params.limit * (page - 1))
|
|
366
|
+
.limit(params.limit);
|
|
340
367
|
}
|
|
341
368
|
return aggregate
|
|
342
369
|
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
343
370
|
.exec();
|
|
344
371
|
});
|
|
345
372
|
}
|
|
373
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
374
|
+
// public async searchSeatsNext(params: factory.place.seat.ISearchConditions): Promise<factory.place.seat.IPlace[]> {
|
|
375
|
+
// // unwindごとのフィルターを分離する(unwind,matchの順序を最適化するため)(2025-04-27~)
|
|
376
|
+
// const filterQueries4screeningRoom: FilterQuery<factory.place.screeningRoom.IPlace>[] = [
|
|
377
|
+
// { typeOf: { $eq: factory.placeType.ScreeningRoom } }
|
|
378
|
+
// ];
|
|
379
|
+
// const filterQueries4section: FilterQuery<factory.place.screeningRoomSection.IPlace>[] = [];
|
|
380
|
+
// const filterQueries4seat: FilterQuery<factory.place.seat.IPlace>[] = [];
|
|
381
|
+
// const projectIdEq = params.project?.id?.$eq;
|
|
382
|
+
// if (typeof projectIdEq === 'string') {
|
|
383
|
+
// filterQueries4screeningRoom.push({ 'project.id': { $eq: projectIdEq } });
|
|
384
|
+
// }
|
|
385
|
+
// const parentOrganizationIdEq = params.parentOrganization?.id?.$eq;
|
|
386
|
+
// if (typeof parentOrganizationIdEq === 'string') {
|
|
387
|
+
// filterQueries4screeningRoom.push({ 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } });
|
|
388
|
+
// }
|
|
389
|
+
// if (params.containedInPlace !== undefined) {
|
|
390
|
+
// if (params.containedInPlace.containedInPlace !== undefined) {
|
|
391
|
+
// if (params.containedInPlace.containedInPlace.containedInPlace !== undefined) {
|
|
392
|
+
// if (params.containedInPlace.containedInPlace.containedInPlace.branchCode !== undefined) {
|
|
393
|
+
// // 施設コード
|
|
394
|
+
// if (typeof params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
|
|
395
|
+
// filterQueries4screeningRoom.push({
|
|
396
|
+
// 'containedInPlace.branchCode': {
|
|
397
|
+
// // $exists: true, // 必ず存在するので削除(2025-04-27~)
|
|
398
|
+
// $eq: params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq
|
|
399
|
+
// }
|
|
400
|
+
// });
|
|
401
|
+
// }
|
|
402
|
+
// }
|
|
403
|
+
// }
|
|
404
|
+
// if (params.containedInPlace.containedInPlace.branchCode !== undefined) {
|
|
405
|
+
// // ルームコード
|
|
406
|
+
// if (typeof params.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
|
|
407
|
+
// filterQueries4screeningRoom.push({
|
|
408
|
+
// branchCode: {
|
|
409
|
+
// $eq: params.containedInPlace.containedInPlace.branchCode.$eq
|
|
410
|
+
// }
|
|
411
|
+
// });
|
|
412
|
+
// }
|
|
413
|
+
// }
|
|
414
|
+
// }
|
|
415
|
+
// }
|
|
416
|
+
// // セクションコード
|
|
417
|
+
// const containedInPlaceBranchCodeEq = params.containedInPlace?.branchCode?.$eq;
|
|
418
|
+
// if (typeof containedInPlaceBranchCodeEq === 'string') {
|
|
419
|
+
// filterQueries4section.push({
|
|
420
|
+
// 'containsPlace.branchCode': {
|
|
421
|
+
// $exists: true,
|
|
422
|
+
// $eq: containedInPlaceBranchCodeEq
|
|
423
|
+
// }
|
|
424
|
+
// });
|
|
425
|
+
// }
|
|
426
|
+
// // セクションコード
|
|
427
|
+
// const containedInPlaceBranchCodeIn = params.containedInPlace?.branchCode?.$in;
|
|
428
|
+
// if (Array.isArray(containedInPlaceBranchCodeIn)) {
|
|
429
|
+
// filterQueries4section.push({
|
|
430
|
+
// 'containsPlace.branchCode': {
|
|
431
|
+
// $exists: true,
|
|
432
|
+
// $in: containedInPlaceBranchCodeIn
|
|
433
|
+
// }
|
|
434
|
+
// });
|
|
435
|
+
// }
|
|
436
|
+
// // 座席コード
|
|
437
|
+
// if (params.branchCode !== undefined) {
|
|
438
|
+
// if (typeof params.branchCode.$eq === 'string') {
|
|
439
|
+
// filterQueries4seat.push({
|
|
440
|
+
// 'containsPlace.containsPlace.branchCode': {
|
|
441
|
+
// $exists: true,
|
|
442
|
+
// $eq: params.branchCode.$eq
|
|
443
|
+
// }
|
|
444
|
+
// });
|
|
445
|
+
// }
|
|
446
|
+
// }
|
|
447
|
+
// const branchCodeIn = params.branchCode?.$in;
|
|
448
|
+
// if (Array.isArray(branchCodeIn)) {
|
|
449
|
+
// filterQueries4seat.push({
|
|
450
|
+
// 'containsPlace.containsPlace.branchCode': {
|
|
451
|
+
// $exists: true,
|
|
452
|
+
// $in: branchCodeIn
|
|
453
|
+
// }
|
|
454
|
+
// });
|
|
455
|
+
// }
|
|
456
|
+
// const branchCodeRegex = params.branchCode?.$regex;
|
|
457
|
+
// if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
|
|
458
|
+
// filterQueries4seat.push({
|
|
459
|
+
// 'containsPlace.containsPlace.branchCode': {
|
|
460
|
+
// $exists: true,
|
|
461
|
+
// $regex: new RegExp(branchCodeRegex)
|
|
462
|
+
// }
|
|
463
|
+
// });
|
|
464
|
+
// }
|
|
465
|
+
// const nameRegex = params.name?.$regex;
|
|
466
|
+
// if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
467
|
+
// filterQueries4seat.push({
|
|
468
|
+
// $or: [
|
|
469
|
+
// {
|
|
470
|
+
// 'containsPlace.containsPlace.name.ja': {
|
|
471
|
+
// $exists: true,
|
|
472
|
+
// $regex: new RegExp(nameRegex)
|
|
473
|
+
// }
|
|
474
|
+
// },
|
|
475
|
+
// {
|
|
476
|
+
// 'containsPlace.containsPlace.name.en': {
|
|
477
|
+
// $exists: true,
|
|
478
|
+
// $regex: new RegExp(nameRegex)
|
|
479
|
+
// }
|
|
480
|
+
// }
|
|
481
|
+
// ]
|
|
482
|
+
// });
|
|
483
|
+
// }
|
|
484
|
+
// const seatingTypeEq = params.seatingType?.$eq;
|
|
485
|
+
// if (typeof seatingTypeEq === 'string') {
|
|
486
|
+
// filterQueries4seat.push({
|
|
487
|
+
// 'containsPlace.containsPlace.seatingType': {
|
|
488
|
+
// $exists: true,
|
|
489
|
+
// $eq: seatingTypeEq
|
|
490
|
+
// }
|
|
491
|
+
// });
|
|
492
|
+
// }
|
|
493
|
+
// const additionalPropertyElemMatch = params.additionalProperty?.$elemMatch;
|
|
494
|
+
// if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
495
|
+
// filterQueries4seat.push({
|
|
496
|
+
// 'containsPlace.containsPlace.additionalProperty': {
|
|
497
|
+
// $exists: true,
|
|
498
|
+
// $elemMatch: additionalPropertyElemMatch
|
|
499
|
+
// }
|
|
500
|
+
// });
|
|
501
|
+
// }
|
|
502
|
+
// const matchStage4screeningRoom: IMatchStage = { $match: { $and: filterQueries4screeningRoom } };
|
|
503
|
+
// const matchStage4section: IMatchStage | undefined = (filterQueries4section.length > 0)
|
|
504
|
+
// ? { $match: { $and: filterQueries4section } }
|
|
505
|
+
// : undefined;
|
|
506
|
+
// const matchStage4seat: IMatchStage | undefined = (filterQueries4seat.length > 0)
|
|
507
|
+
// ? { $match: { $and: filterQueries4seat } }
|
|
508
|
+
// : undefined;
|
|
509
|
+
// const projectStage = SeatRepo.CREATE_SEARCH_SEATS_PROJECTION({ ...params.$projection });
|
|
510
|
+
// const pipeline: PipelineStage[] = [
|
|
511
|
+
// matchStage4screeningRoom,
|
|
512
|
+
// { $unwind: '$containsPlace' },
|
|
513
|
+
// ...(matchStage4section !== undefined) ? [matchStage4section] : [],
|
|
514
|
+
// { $unwind: '$containsPlace.containsPlace' },
|
|
515
|
+
// ...(matchStage4seat !== undefined) ? [matchStage4seat] : [],
|
|
516
|
+
// { $project: projectStage }
|
|
517
|
+
// ];
|
|
518
|
+
// // console.dir(pipeline, { depth: null });
|
|
519
|
+
// const aggregate = this.placeModel.aggregate<factory.place.seat.IPlace>(pipeline);
|
|
520
|
+
// if (typeof params.limit === 'number' && params.limit > 0) {
|
|
521
|
+
// const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
522
|
+
// aggregate.limit(params.limit * page)
|
|
523
|
+
// .skip(params.limit * (page - 1));
|
|
524
|
+
// }
|
|
525
|
+
// return aggregate
|
|
526
|
+
// .option({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
527
|
+
// .exec();
|
|
528
|
+
// }
|
|
346
529
|
/**
|
|
347
530
|
* 座席区分集計検索
|
|
348
531
|
*/
|
|
@@ -8,7 +8,7 @@ import type { OfferRepo } from '../../../repo/offer';
|
|
|
8
8
|
import type { OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
9
9
|
import type { OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
|
|
10
10
|
import type { PaymentServiceRepo } from '../../../repo/paymentService';
|
|
11
|
-
import
|
|
11
|
+
import { SeatRepo } from '../../../repo/place/seat';
|
|
12
12
|
import type { PriceSpecificationRepo } from '../../../repo/priceSpecification';
|
|
13
13
|
import type { ProductRepo } from '../../../repo/product';
|
|
14
14
|
import type { ProductOfferRepo } from '../../../repo/productOffer';
|
|
@@ -14,6 +14,7 @@ const createDebug = require("debug");
|
|
|
14
14
|
const moment = require("moment");
|
|
15
15
|
const factory = require("../../../factory");
|
|
16
16
|
const pecorinoapi = require("../../../pecorinoapi");
|
|
17
|
+
const seat_1 = require("../../../repo/place/seat");
|
|
17
18
|
const OfferService = require("../../offer");
|
|
18
19
|
const searchOffersByIds_1 = require("../../offer/event/searchOffersByIds");
|
|
19
20
|
const cancelReservation_1 = require("../../reserve/cancelReservation");
|
|
@@ -23,7 +24,6 @@ const createPointAward_1 = require("./start/factory/createPointAward");
|
|
|
23
24
|
const createStartParams_1 = require("./start/factory/createStartParams");
|
|
24
25
|
const validateStartRequest_1 = require("./validateStartRequest");
|
|
25
26
|
const debug = createDebug('chevre-domain:service:assetTransaction:reserve');
|
|
26
|
-
const DEFAULT_MAXIMUM_CAPACITY = 10000;
|
|
27
27
|
const ONE_MONTH_IN_DAYS = 31;
|
|
28
28
|
/**
|
|
29
29
|
* 取引開始
|
|
@@ -544,7 +544,7 @@ function processLockSeats(params) {
|
|
|
544
544
|
// 座席無の場合デフォルトmaximumAttendeeCapacityを適用(2025-04-20~)
|
|
545
545
|
if (!hasTicketedSeat) {
|
|
546
546
|
if (typeof maximumAttendeeCapacity4event !== 'number') {
|
|
547
|
-
maximumAttendeeCapacity4event =
|
|
547
|
+
maximumAttendeeCapacity4event = seat_1.DEFAULT_ROOM_MAXIMUM_CAPACITY;
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
550
|
if (typeof maximumAttendeeCapacity4event === 'number') {
|
package/package.json
CHANGED