@chevre/domain 21.2.0-alpha.133 → 21.2.0-alpha.135
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/searchHoldReservations.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/holdReservation.js +1 -0
- package/lib/chevre/repo/place.d.ts +2 -8
- package/lib/chevre/repo/place.js +58 -34
- package/lib/chevre/repo/stockHolder.js +10 -6
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +9 -9
- package/lib/chevre/service/task/onResourceUpdated.js +9 -3
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import * as redis from 'redis';
|
|
|
6
6
|
import { chevre } from '../../../lib/index';
|
|
7
7
|
|
|
8
8
|
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex:
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
|
|
10
10
|
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
11
11
|
socket: {
|
|
12
12
|
host: process.env.REDIS_HOST,
|
|
@@ -60,6 +60,7 @@ schema.index({ 'reservationFor.startDate': -1 }, { name: 'searchByReservationFor
|
|
|
60
60
|
schema.index({ 'reservationFor.id': 1 }, { name: 'uniqueReservationForId', unique: true });
|
|
61
61
|
schema.index({ 'reservationFor.id': 1, 'reservationFor.startDate': -1 }, { name: 'searchByReservationForId' });
|
|
62
62
|
schema.index({ 'project.id': 1, 'reservationFor.startDate': -1 }, { name: 'searchByProjectId' });
|
|
63
|
+
schema.index({ reservationCount: 1, 'reservationFor.startDate': -1 }, { name: 'searchByReservationCount' });
|
|
63
64
|
schema.index({ 'reservations.reservationNumber': 1, 'reservationFor.startDate': -1 }, {
|
|
64
65
|
name: 'searchByReservationNumber',
|
|
65
66
|
partialFilterExpression: {
|
|
@@ -48,17 +48,11 @@ export declare class MongoRepository {
|
|
|
48
48
|
/**
|
|
49
49
|
* 施設検索
|
|
50
50
|
*/
|
|
51
|
-
searchMovieTheaters(params: factory.place.movieTheater.ISearchConditions & {
|
|
52
|
-
$projection?: {
|
|
53
|
-
[key: string]: 0;
|
|
54
|
-
};
|
|
55
|
-
}): Promise<factory.place.movieTheater.IPlaceWithoutScreeningRoom[]>;
|
|
51
|
+
searchMovieTheaters(params: factory.place.movieTheater.ISearchConditions & {}, inclusion: string[], exclusion: string[]): Promise<factory.place.movieTheater.IPlaceWithoutScreeningRoom[]>;
|
|
56
52
|
/**
|
|
57
53
|
* 施設取得
|
|
54
|
+
* 廃止(2023-06-22~)
|
|
58
55
|
*/
|
|
59
|
-
findById(params: {
|
|
60
|
-
id: string;
|
|
61
|
-
}, inclusion: string[], exclusion: string[]): Promise<factory.place.movieTheater.IPlace>;
|
|
62
56
|
deleteMovieTheaterById(params: {
|
|
63
57
|
id: string;
|
|
64
58
|
}): Promise<void>;
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -277,34 +277,12 @@ class MongoRepository {
|
|
|
277
277
|
/**
|
|
278
278
|
* 施設検索
|
|
279
279
|
*/
|
|
280
|
-
searchMovieTheaters(params
|
|
280
|
+
searchMovieTheaters(params,
|
|
281
|
+
// projection明示指定化(2023-06-22~)
|
|
282
|
+
inclusion, exclusion) {
|
|
281
283
|
var _a;
|
|
282
284
|
return __awaiter(this, void 0, void 0, function* () {
|
|
283
285
|
const conditions = MongoRepository.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
|
|
284
|
-
// containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
|
|
285
|
-
const query = this.placeModel.find((conditions.length > 0) ? { $and: conditions } : {}, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0, containsPlace: 0 }, params.$projection));
|
|
286
|
-
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
287
|
-
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
288
|
-
query.limit(params.limit)
|
|
289
|
-
.skip(params.limit * (page - 1));
|
|
290
|
-
}
|
|
291
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
292
|
-
/* istanbul ignore else */
|
|
293
|
-
if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.branchCode) !== undefined) {
|
|
294
|
-
query.sort({ branchCode: params.sort.branchCode });
|
|
295
|
-
}
|
|
296
|
-
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
297
|
-
.exec()
|
|
298
|
-
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* 施設取得
|
|
303
|
-
*/
|
|
304
|
-
findById(params,
|
|
305
|
-
// projection?: any
|
|
306
|
-
inclusion, exclusion) {
|
|
307
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
308
286
|
let projection = {};
|
|
309
287
|
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
310
288
|
inclusion.forEach((field) => {
|
|
@@ -315,7 +293,9 @@ class MongoRepository {
|
|
|
315
293
|
projection = {
|
|
316
294
|
__v: 0,
|
|
317
295
|
createdAt: 0,
|
|
318
|
-
updatedAt: 0
|
|
296
|
+
updatedAt: 0,
|
|
297
|
+
// containsPlaceを含めるとデータサイズが大きくなるので、検索結果には含めない
|
|
298
|
+
containsPlace: 0
|
|
319
299
|
};
|
|
320
300
|
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
321
301
|
exclusion.forEach((field) => {
|
|
@@ -323,17 +303,61 @@ class MongoRepository {
|
|
|
323
303
|
});
|
|
324
304
|
}
|
|
325
305
|
}
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
if (doc === null) {
|
|
332
|
-
throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
306
|
+
const query = this.placeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
307
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
308
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
309
|
+
query.limit(params.limit)
|
|
310
|
+
.skip(params.limit * (page - 1));
|
|
333
311
|
}
|
|
334
|
-
|
|
312
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
313
|
+
/* istanbul ignore else */
|
|
314
|
+
if (((_a = params.sort) === null || _a === void 0 ? void 0 : _a.branchCode) !== undefined) {
|
|
315
|
+
query.sort({ branchCode: params.sort.branchCode });
|
|
316
|
+
}
|
|
317
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
318
|
+
.exec()
|
|
319
|
+
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
335
320
|
});
|
|
336
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* 施設取得
|
|
324
|
+
* 廃止(2023-06-22~)
|
|
325
|
+
*/
|
|
326
|
+
// public async findById(
|
|
327
|
+
// params: { id: string },
|
|
328
|
+
// inclusion: string[],
|
|
329
|
+
// exclusion: string[]
|
|
330
|
+
// ): Promise<factory.place.movieTheater.IPlace> {
|
|
331
|
+
// let projection: { [key: string]: number } = {};
|
|
332
|
+
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
333
|
+
// inclusion.forEach((field) => {
|
|
334
|
+
// projection[field] = 1;
|
|
335
|
+
// });
|
|
336
|
+
// } else {
|
|
337
|
+
// projection = {
|
|
338
|
+
// __v: 0,
|
|
339
|
+
// createdAt: 0,
|
|
340
|
+
// updatedAt: 0
|
|
341
|
+
// };
|
|
342
|
+
// if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
343
|
+
// exclusion.forEach((field) => {
|
|
344
|
+
// projection[field] = 0;
|
|
345
|
+
// });
|
|
346
|
+
// }
|
|
347
|
+
// }
|
|
348
|
+
// const doc = await this.placeModel.findOne(
|
|
349
|
+
// {
|
|
350
|
+
// typeOf: { $eq: factory.placeType.MovieTheater },
|
|
351
|
+
// _id: { $eq: params.id }
|
|
352
|
+
// },
|
|
353
|
+
// projection
|
|
354
|
+
// )
|
|
355
|
+
// .exec();
|
|
356
|
+
// if (doc === null) {
|
|
357
|
+
// throw new factory.errors.NotFound(this.placeModel.modelName);
|
|
358
|
+
// }
|
|
359
|
+
// return doc.toObject();
|
|
360
|
+
// }
|
|
337
361
|
deleteMovieTheaterById(params) {
|
|
338
362
|
return __awaiter(this, void 0, void 0, function* () {
|
|
339
363
|
yield this.placeModel.findOneAndDelete({
|
|
@@ -118,7 +118,7 @@ class StockHolderRepository {
|
|
|
118
118
|
}
|
|
119
119
|
yield this.checkIfConflicted({ key: '', eventId: lockKey.eventId, useMongoose });
|
|
120
120
|
// reservationCount<=nであれば$push+$incする
|
|
121
|
-
yield this.initializeHoldReservation({ project: lockKey.project, eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
121
|
+
const { id } = yield this.initializeHoldReservation({ project: lockKey.project, eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
122
122
|
const addedReservationCount = lockKey.offers.length;
|
|
123
123
|
const reservationCountLte = maximum - addedReservationCount;
|
|
124
124
|
const subReservations = lockKey.offers.map((offer) => StockHolderRepository.offer2subReservation(offer, lockKey.hasTicketedSeat));
|
|
@@ -128,8 +128,9 @@ class StockHolderRepository {
|
|
|
128
128
|
subReservation: subReservations
|
|
129
129
|
};
|
|
130
130
|
yield this.holdReservationModel.findOneAndUpdate({
|
|
131
|
+
_id: { $eq: id },
|
|
131
132
|
reservationCount: { $lte: reservationCountLte },
|
|
132
|
-
'reservationFor.id': { $eq: lockKey.eventId },
|
|
133
|
+
// 'reservationFor.id': { $eq: lockKey.eventId },
|
|
133
134
|
// 座席有無に関わらずsubReservation.identifierはuniqueであるはず
|
|
134
135
|
'reservations.subReservation.identifier': {
|
|
135
136
|
$nin: subReservations.map((r) => r.identifier)
|
|
@@ -177,7 +178,7 @@ class StockHolderRepository {
|
|
|
177
178
|
const key = StockHolderRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
178
179
|
yield this.checkIfConflicted({ key, eventId: lockKey.eventId, useMongoose });
|
|
179
180
|
if (useMongoose) {
|
|
180
|
-
yield this.initializeHoldReservation({ project: lockKey.project, eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
181
|
+
const { id } = yield this.initializeHoldReservation({ project: lockKey.project, eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
181
182
|
const addedReservationCount = lockKey.offers.length;
|
|
182
183
|
const subReservations = lockKey.offers.map((offer) => StockHolderRepository.offer2subReservation(offer, lockKey.hasTicketedSeat));
|
|
183
184
|
const reservationPackage = {
|
|
@@ -186,7 +187,8 @@ class StockHolderRepository {
|
|
|
186
187
|
subReservation: subReservations
|
|
187
188
|
};
|
|
188
189
|
yield this.holdReservationModel.findOneAndUpdate({
|
|
189
|
-
|
|
190
|
+
_id: { $eq: id },
|
|
191
|
+
// 'reservationFor.id': { $eq: lockKey.eventId },
|
|
190
192
|
// 座席有無に関わらずsubReservation.identifierはuniqueであるはず
|
|
191
193
|
'reservations.subReservation.identifier': {
|
|
192
194
|
$nin: subReservations.map((r) => r.identifier)
|
|
@@ -727,11 +729,13 @@ class StockHolderRepository {
|
|
|
727
729
|
},
|
|
728
730
|
reservations: []
|
|
729
731
|
};
|
|
730
|
-
const initializedResult = yield this.holdReservationModel.
|
|
732
|
+
const initializedResult = yield this.holdReservationModel.findOneAndUpdate({ 'reservationFor.id': { $eq: params.eventId } }, {
|
|
731
733
|
$setOnInsert: aggregateReservation
|
|
732
|
-
}, { upsert: true })
|
|
734
|
+
}, { new: true, upsert: true })
|
|
735
|
+
.select({ _id: 1 })
|
|
733
736
|
.exec();
|
|
734
737
|
debug('holdReservation initialized', initializedResult, params.eventId);
|
|
738
|
+
return { id: initializedResult.id };
|
|
735
739
|
});
|
|
736
740
|
}
|
|
737
741
|
}
|
|
@@ -59,15 +59,15 @@ function findEntranceGates(params) {
|
|
|
59
59
|
const searchMovieTheatersResult = yield repos.place.searchMovieTheaters({
|
|
60
60
|
limit: 1,
|
|
61
61
|
page: 1,
|
|
62
|
-
id: { $eq: params.event.superEvent.location.id }
|
|
63
|
-
$projection: {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
});
|
|
62
|
+
id: { $eq: params.event.superEvent.location.id }
|
|
63
|
+
// $projection: {
|
|
64
|
+
// containsPlace: 0,
|
|
65
|
+
// hasPOS: 0,
|
|
66
|
+
// offers: 0,
|
|
67
|
+
// parentOrganization: 0,
|
|
68
|
+
// name: 0
|
|
69
|
+
// }
|
|
70
|
+
}, ['hasEntranceGate'], []);
|
|
71
71
|
movieTheater = searchMovieTheatersResult.shift();
|
|
72
72
|
// movieTheater = await repos.place.findById(
|
|
73
73
|
// { id: params.event.superEvent.location.id },
|
|
@@ -231,7 +231,12 @@ function createInformMovieTheaterTasks(params) {
|
|
|
231
231
|
if (params.ids.length !== 1) {
|
|
232
232
|
throw new factory.errors.Argument('id', 'id.length must be 1');
|
|
233
233
|
}
|
|
234
|
-
const
|
|
234
|
+
const movieTheaters = yield repos.place.searchMovieTheaters({
|
|
235
|
+
limit: 1,
|
|
236
|
+
page: 1,
|
|
237
|
+
project: { id: { $eq: params.project.id } },
|
|
238
|
+
id: { $eq: params.ids[0] }
|
|
239
|
+
}, [
|
|
235
240
|
'additionalProperty',
|
|
236
241
|
'branchCode',
|
|
237
242
|
'hasEntranceGate',
|
|
@@ -249,8 +254,9 @@ function createInformMovieTheaterTasks(params) {
|
|
|
249
254
|
// 'containsPlace.additionalProperty',
|
|
250
255
|
// 'containsPlace.address'
|
|
251
256
|
], []);
|
|
252
|
-
|
|
253
|
-
|
|
257
|
+
const movieTheater = movieTheaters.shift();
|
|
258
|
+
if (movieTheater === undefined) {
|
|
259
|
+
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
254
260
|
}
|
|
255
261
|
// ルームを検索
|
|
256
262
|
const screeningRooms = yield repos.place.searchScreeningRooms({
|
package/package.json
CHANGED