@chevre/domain 21.2.0-alpha.123 → 21.2.0-alpha.124
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.
|
@@ -140,6 +140,9 @@ export declare class StockHolderRepository {
|
|
|
140
140
|
id?: {
|
|
141
141
|
$eq?: string;
|
|
142
142
|
};
|
|
143
|
+
identifier?: {
|
|
144
|
+
$eq?: string;
|
|
145
|
+
};
|
|
143
146
|
reservedTicket?: {
|
|
144
147
|
ticketedSeat?: {
|
|
145
148
|
seatNumber?: {
|
|
@@ -152,5 +155,6 @@ export declare class StockHolderRepository {
|
|
|
152
155
|
};
|
|
153
156
|
}): Promise<ISearchSubReservationResult[]>;
|
|
154
157
|
private checkIfConflicted;
|
|
158
|
+
private checkIfConflictedBetweenRedisAndMongo;
|
|
155
159
|
private initializeHoldReservation;
|
|
156
160
|
}
|
|
@@ -86,6 +86,7 @@ class StockHolderRepository {
|
|
|
86
86
|
lockIfNotLimitExceeded(lockKey, maximum) {
|
|
87
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
88
|
if (StockHolderRepository.useMongoose({ eventId: lockKey.eventId, startDate: lockKey.startDate })) {
|
|
89
|
+
yield this.checkIfConflictedBetweenRedisAndMongo({ key: '', eventId: lockKey.eventId });
|
|
89
90
|
// reservationCount<=nであれば$push+$incする
|
|
90
91
|
yield this.initializeHoldReservation({ project: lockKey.project, eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
91
92
|
const addedReservationCount = lockKey.offers.length;
|
|
@@ -135,6 +136,7 @@ class StockHolderRepository {
|
|
|
135
136
|
lock(lockKey) {
|
|
136
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
138
|
if (StockHolderRepository.useMongoose({ eventId: lockKey.eventId, startDate: lockKey.startDate })) {
|
|
139
|
+
yield this.checkIfConflictedBetweenRedisAndMongo({ key: '', eventId: lockKey.eventId });
|
|
138
140
|
yield this.initializeHoldReservation({ project: lockKey.project, eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
139
141
|
const addedReservationCount = lockKey.offers.length;
|
|
140
142
|
const subReservations = lockKey.offers.map((offer) => StockHolderRepository.offer2subReservation(offer));
|
|
@@ -214,6 +216,7 @@ class StockHolderRepository {
|
|
|
214
216
|
unlock(params) {
|
|
215
217
|
return __awaiter(this, void 0, void 0, function* () {
|
|
216
218
|
if (StockHolderRepository.useMongoose({ eventId: params.eventId, startDate: params.startDate })) {
|
|
219
|
+
yield this.checkIfConflictedBetweenRedisAndMongo({ key: '', eventId: params.eventId });
|
|
217
220
|
// [id]あるいは[seatNumber+seatSection]でreservations.subReservationsから$pull+$incする
|
|
218
221
|
yield this.initializeHoldReservation({ project: params.project, eventId: params.eventId, startDate: params.startDate });
|
|
219
222
|
const subReservation = StockHolderRepository.offer2subReservation(params.offer);
|
|
@@ -451,13 +454,9 @@ class StockHolderRepository {
|
|
|
451
454
|
* 汎用的な検索(mongooseのみ対応)
|
|
452
455
|
*/
|
|
453
456
|
search(params) {
|
|
454
|
-
var _a, _b, _c, _d, _e;
|
|
457
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
455
458
|
return __awaiter(this, void 0, void 0, function* () {
|
|
456
|
-
const matchStages = [
|
|
457
|
-
// {
|
|
458
|
-
// $match: { 'reservations.subReservation.identifier': { $in: subReservations.map((r) => r.identifier) } }
|
|
459
|
-
// }
|
|
460
|
-
];
|
|
459
|
+
const matchStages = [];
|
|
461
460
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
462
461
|
if (typeof projectIdEq === 'string') {
|
|
463
462
|
matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
|
|
@@ -470,6 +469,43 @@ class StockHolderRepository {
|
|
|
470
469
|
if (typeof reservationNumberEq === 'string') {
|
|
471
470
|
matchStages.push({ $match: { 'reservations.reservationNumber': { $eq: reservationNumberEq } } });
|
|
472
471
|
}
|
|
472
|
+
const identifierEq = (_f = params.identifier) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
473
|
+
if (typeof identifierEq === 'string') {
|
|
474
|
+
matchStages.push({ $match: { 'reservations.subReservation.identifier': { $eq: identifierEq } } });
|
|
475
|
+
}
|
|
476
|
+
const idEq = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
477
|
+
if (typeof idEq === 'string') {
|
|
478
|
+
matchStages.push({
|
|
479
|
+
$match: {
|
|
480
|
+
'reservations.subReservation.id': {
|
|
481
|
+
$exists: true,
|
|
482
|
+
$eq: idEq
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
const seatNumberEq = (_k = (_j = (_h = params.reservedTicket) === null || _h === void 0 ? void 0 : _h.ticketedSeat) === null || _j === void 0 ? void 0 : _j.seatNumber) === null || _k === void 0 ? void 0 : _k.$eq;
|
|
488
|
+
if (typeof seatNumberEq === 'string') {
|
|
489
|
+
matchStages.push({
|
|
490
|
+
$match: {
|
|
491
|
+
'reservations.subReservation.reservedTicket.ticketedSeat.seatNumber': {
|
|
492
|
+
$exists: true,
|
|
493
|
+
$eq: seatNumberEq
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
const seatSectionEq = (_o = (_m = (_l = params.reservedTicket) === null || _l === void 0 ? void 0 : _l.ticketedSeat) === null || _m === void 0 ? void 0 : _m.seatSection) === null || _o === void 0 ? void 0 : _o.$eq;
|
|
499
|
+
if (typeof seatSectionEq === 'string') {
|
|
500
|
+
matchStages.push({
|
|
501
|
+
$match: {
|
|
502
|
+
'reservations.subReservation.reservedTicket.ticketedSeat.seatSection': {
|
|
503
|
+
$exists: true,
|
|
504
|
+
$eq: seatSectionEq
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
}
|
|
473
509
|
const aggregate = this.holdReservationModel.aggregate([
|
|
474
510
|
{ $unwind: '$reservations' },
|
|
475
511
|
{ $unwind: '$reservations.subReservation' },
|
|
@@ -490,7 +526,8 @@ class StockHolderRepository {
|
|
|
490
526
|
aggregate.limit(params.limit * page)
|
|
491
527
|
.skip(params.limit * (page - 1));
|
|
492
528
|
}
|
|
493
|
-
return aggregate.
|
|
529
|
+
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
530
|
+
.exec();
|
|
494
531
|
});
|
|
495
532
|
}
|
|
496
533
|
checkIfConflicted(params) {
|
|
@@ -516,6 +553,13 @@ class StockHolderRepository {
|
|
|
516
553
|
}
|
|
517
554
|
});
|
|
518
555
|
}
|
|
556
|
+
// tslint:disable-next-line:prefer-function-over-method
|
|
557
|
+
checkIfConflictedBetweenRedisAndMongo(__) {
|
|
558
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
559
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
560
|
+
// TODO implement
|
|
561
|
+
});
|
|
562
|
+
}
|
|
519
563
|
initializeHoldReservation(params) {
|
|
520
564
|
return __awaiter(this, void 0, void 0, function* () {
|
|
521
565
|
if (!(params.startDate instanceof Date)) {
|
package/package.json
CHANGED