@chevre/domain 21.2.0-alpha.132 → 21.2.0-alpha.134

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.
@@ -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: false });
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: {
@@ -73,6 +73,8 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
73
73
  smokingAllowed?: boolean | undefined;
74
74
  sameAs?: string | undefined;
75
75
  parentOrganization?: any;
76
+ openSeatingAllowed?: any;
77
+ amenityFeature?: any;
76
78
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
77
79
  typeOf: string;
78
80
  additionalProperty: any[];
@@ -95,6 +97,8 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
95
97
  smokingAllowed?: boolean | undefined;
96
98
  sameAs?: string | undefined;
97
99
  parentOrganization?: any;
100
+ openSeatingAllowed?: any;
101
+ amenityFeature?: any;
98
102
  }>> & Omit<import("mongoose").FlatRecord<{
99
103
  typeOf: string;
100
104
  additionalProperty: any[];
@@ -117,6 +121,8 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
117
121
  smokingAllowed?: boolean | undefined;
118
122
  sameAs?: string | undefined;
119
123
  parentOrganization?: any;
124
+ openSeatingAllowed?: any;
125
+ amenityFeature?: any;
120
126
  }> & {
121
127
  _id: import("mongoose").Types.ObjectId;
122
128
  }, never>>;
@@ -32,7 +32,10 @@ const schema = new mongoose_1.Schema({
32
32
  kanaName: String,
33
33
  offers: mongoose_1.SchemaTypes.Mixed,
34
34
  additionalProperty: [mongoose_1.SchemaTypes.Mixed],
35
- parentOrganization: mongoose_1.SchemaTypes.Mixed
35
+ parentOrganization: mongoose_1.SchemaTypes.Mixed,
36
+ // ↓ルームの施設からの分離に伴い属性追加(2023-06-22~)
37
+ openSeatingAllowed: mongoose_1.SchemaTypes.Mixed,
38
+ amenityFeature: mongoose_1.SchemaTypes.Mixed
36
39
  }, {
37
40
  collection: 'places',
38
41
  id: true,
@@ -132,3 +135,15 @@ schema.index({ 'containsPlace.containsPlace.containsPlace.additionalProperty': 1
132
135
  'containsPlace.containsPlace.containsPlace.additionalProperty': { $exists: true }
133
136
  }
134
137
  });
138
+ schema.index({ 'containedInPlace.id': 1, branchCode: 1 }, {
139
+ name: 'searchByContainedInPlaceId',
140
+ partialFilterExpression: {
141
+ 'containedInPlace.id': { $exists: true }
142
+ }
143
+ });
144
+ schema.index({ 'containedInPlace.branchCode': 1, branchCode: 1 }, {
145
+ name: 'searchByContainedInPlaceBranchCode',
146
+ partialFilterExpression: {
147
+ 'containedInPlace.branchCode': { $exists: true }
148
+ }
149
+ });
@@ -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
- 'reservationFor.id': { $eq: lockKey.eventId },
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.updateOne({ 'reservationFor.id': { $eq: params.eventId } }, {
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
  }
@@ -56,16 +56,25 @@ function findEntranceGates(params) {
56
56
  return (repos) => __awaiter(this, void 0, void 0, function* () {
57
57
  let movieTheater;
58
58
  try {
59
- movieTheater = yield repos.place.findById({ id: params.event.superEvent.location.id },
60
- // 不要な属性を取得しない
61
- ['hasEntranceGate'], []
62
- // {
63
- // containsPlace: 0,
64
- // hasPOS: 0,
65
- // offers: 0,
66
- // parentOrganization: 0
67
- // }
68
- );
59
+ const searchMovieTheatersResult = yield repos.place.searchMovieTheaters({
60
+ limit: 1,
61
+ page: 1,
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
+ });
71
+ movieTheater = searchMovieTheatersResult.shift();
72
+ // movieTheater = await repos.place.findById(
73
+ // { id: params.event.superEvent.location.id },
74
+ // // 不要な属性を取得しない
75
+ // ['hasEntranceGate'],
76
+ // []
77
+ // );
69
78
  }
70
79
  catch (error) {
71
80
  let throwsError = true;
@@ -66,6 +66,13 @@ function onResourceUpdated(params) {
66
66
  ids: params.id,
67
67
  typeOf: params.typeOf
68
68
  })(repos);
69
+ // tslint:disable-next-line:no-suspicious-comment
70
+ // TODO ルーム同期タスクを作成
71
+ yield syncScreeningRooms({
72
+ project: { id: params.project.id },
73
+ ids: params.id,
74
+ typeOf: params.typeOf
75
+ })(repos);
69
76
  break;
70
77
  case 'AccountTitle':
71
78
  yield createInformAccountTitleTasks({
@@ -235,17 +242,29 @@ function createInformMovieTheaterTasks(params) {
235
242
  'project',
236
243
  'telephone',
237
244
  'url',
238
- 'typeOf',
239
- 'containsPlace.branchCode',
240
- 'containsPlace.name',
241
- 'containsPlace.typeOf',
242
- 'containsPlace.additionalProperty',
243
- 'containsPlace.address'
245
+ 'typeOf'
246
+ // 'containsPlace.branchCode',
247
+ // 'containsPlace.name',
248
+ // 'containsPlace.typeOf',
249
+ // 'containsPlace.additionalProperty',
250
+ // 'containsPlace.address'
244
251
  ], []);
245
252
  if (movieTheater.project.id !== params.project.id) {
246
253
  throw new factory.errors.Argument('project.id', 'project.id not matched');
247
254
  }
248
- const movieTheaters4inform = [movieTheater];
255
+ // ルームを検索
256
+ const screeningRooms = yield repos.place.searchScreeningRooms({
257
+ containedInPlace: { id: { $eq: movieTheater.id } }
258
+ });
259
+ const movieTheaters4inform = [Object.assign(Object.assign({}, movieTheater), { containsPlace: screeningRooms.map((room) => {
260
+ return {
261
+ branchCode: room.branchCode,
262
+ name: room.name,
263
+ typeOf: room.typeOf,
264
+ additionalProperty: room.additionalProperty,
265
+ address: room.address
266
+ };
267
+ }) })];
249
268
  if (movieTheaters4inform.length > 0) {
250
269
  const taskRunsAt = new Date();
251
270
  const informTasks = [];
@@ -350,3 +369,35 @@ function createInformAccountTitleTasks(params) {
350
369
  }
351
370
  });
352
371
  }
372
+ function syncScreeningRooms(__) {
373
+ return (__2) => __awaiter(this, void 0, void 0, function* () {
374
+ // if (params.ids.length !== 1) {
375
+ // throw new factory.errors.Argument('id', 'id.length must be 1');
376
+ // }
377
+ // const movieTheater = await repos.place.findById(
378
+ // { id: params.ids[0] },
379
+ // [
380
+ // 'additionalProperty',
381
+ // 'branchCode',
382
+ // 'hasEntranceGate',
383
+ // 'hasPOS',
384
+ // 'kanaName',
385
+ // 'name',
386
+ // 'parentOrganization',
387
+ // 'project',
388
+ // 'telephone',
389
+ // 'url',
390
+ // 'typeOf',
391
+ // 'containsPlace.branchCode',
392
+ // 'containsPlace.name',
393
+ // 'containsPlace.typeOf',
394
+ // 'containsPlace.additionalProperty',
395
+ // 'containsPlace.address'
396
+ // ],
397
+ // []
398
+ // );
399
+ // if (movieTheater.project.id !== params.project.id) {
400
+ // throw new factory.errors.Argument('project.id', 'project.id not matched');
401
+ // }
402
+ });
403
+ }
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.2.0-alpha.132"
120
+ "version": "21.2.0-alpha.134"
121
121
  }