@chevre/domain 21.2.0-alpha.152 → 21.2.0-alpha.153

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.
@@ -88,6 +88,12 @@ export declare class MongoRepository {
88
88
  };
89
89
  typeOf: factory.placeType.ScreeningRoom;
90
90
  }>;
91
+ updateScreeningRoomsByContainedInPlaceId(screeningRoom: {
92
+ project: {
93
+ id: string;
94
+ };
95
+ containedInPlace: Pick<factory.place.screeningRoom.IContainedInPlace, 'id' | 'name'>;
96
+ }): Promise<void>;
91
97
  deleteScreeningRoom(screeningRoom: {
92
98
  project: {
93
99
  id: string;
@@ -552,6 +552,21 @@ class MongoRepository {
552
552
  }
553
553
  });
554
554
  }
555
+ updateScreeningRoomsByContainedInPlaceId(screeningRoom) {
556
+ var _a;
557
+ return __awaiter(this, void 0, void 0, function* () {
558
+ if (typeof ((_a = screeningRoom.containedInPlace.name) === null || _a === void 0 ? void 0 : _a.ja) === 'string') {
559
+ yield this.placeModel.updateMany({
560
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
561
+ 'project.id': { $eq: screeningRoom.project.id },
562
+ 'containedInPlace.id': { $exists: true, $eq: screeningRoom.containedInPlace.id }
563
+ }, {
564
+ 'containedInPlace.name': screeningRoom.containedInPlace.name
565
+ })
566
+ .exec();
567
+ }
568
+ });
569
+ }
555
570
  deleteScreeningRoom(screeningRoom, useScreeningRoomType) {
556
571
  return __awaiter(this, void 0, void 0, function* () {
557
572
  if (useScreeningRoomType === true) {
@@ -5,6 +5,3 @@ export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
5
5
  * タスク実行関数
6
6
  */
7
7
  export declare function call(data: factory.task.onResourceUpdated.IData): IOperation<void>;
8
- /**
9
- * 施設のcontainsPlaceをdocumentとして保管する
10
- */
@@ -78,17 +78,18 @@ function onResourceUpdated(params) {
78
78
  // no op
79
79
  }
80
80
  }
81
- // switch (params.typeOf) {
82
- // case factory.placeType.MovieTheater:
83
- // await syncScreeningRooms({
84
- // project: { id: params.project.id },
85
- // ids: params.id,
86
- // typeOf: params.typeOf
87
- // })(repos);
88
- // break;
89
- // default:
90
- // // no op
91
- // }
81
+ switch (params.typeOf) {
82
+ // 施設名称を同期する(2023-06-29~)
83
+ case factory.placeType.MovieTheater:
84
+ yield syncMovieTheater({
85
+ project: { id: params.project.id },
86
+ ids: params.id,
87
+ typeOf: params.typeOf
88
+ })(repos);
89
+ break;
90
+ default:
91
+ // no op
92
+ }
92
93
  });
93
94
  }
94
95
  function createInformMovieTasks(params) {
@@ -374,45 +375,22 @@ function createInformAccountTitleTasks(params) {
374
375
  }
375
376
  });
376
377
  }
377
- /**
378
- * 施設のcontainsPlaceをdocumentとして保管する
379
- */
380
- // function syncScreeningRooms(params: {
381
- // project: { id: string };
382
- // ids: string[];
383
- // typeOf: factory.placeType.MovieTheater;
384
- // }) {
385
- // return async (repos: {
386
- // place: PlaceRepo;
387
- // }) => {
388
- // if (params.ids.length !== 1) {
389
- // throw new factory.errors.Argument('id', 'id.length must be 1');
390
- // }
391
- // const movieTheaters = <Pick<
392
- // factory.place.movieTheater.IPlace,
393
- // 'id' | 'branchCode' | 'name' | 'project' | 'typeOf' | 'containsPlace'
394
- // >[]>
395
- // await repos.place.searchMovieTheaters(
396
- // { id: { $eq: params.ids[0] } },
397
- // ['_id', 'branchCode', 'name', 'project', 'typeOf', 'containsPlace'],
398
- // []
399
- // );
400
- // const movieTheater = movieTheaters.shift();
401
- // if (movieTheater === undefined) {
402
- // throw new factory.errors.NotFound(factory.placeType.MovieTheater);
403
- // }
404
- // const creatingScreeningRooms: factory.place.screeningRoom.IPlace[] = movieTheater.containsPlace.map((place) => {
405
- // return {
406
- // ...place,
407
- // containedInPlace: {
408
- // id: movieTheater.id,
409
- // typeOf: movieTheater.typeOf,
410
- // branchCode: movieTheater.branchCode,
411
- // name: movieTheater.name
412
- // },
413
- // project: movieTheater.project
414
- // };
415
- // });
416
- // debug('sync processing', creatingScreeningRooms.length, 'screeningRooms...');
417
- // };
418
- // }
378
+ function syncMovieTheater(params) {
379
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
380
+ if (params.ids.length !== 1) {
381
+ throw new factory.errors.Argument('id', 'id.length must be 1');
382
+ }
383
+ const movieTheaters = yield repos.place.searchMovieTheaters({
384
+ id: { $eq: params.ids[0] },
385
+ project: { id: { $eq: params.project.id } }
386
+ }, ['_id', 'name'], []);
387
+ const movieTheater = movieTheaters.shift();
388
+ if (movieTheater === undefined) {
389
+ throw new factory.errors.NotFound(factory.placeType.MovieTheater);
390
+ }
391
+ yield repos.place.updateScreeningRoomsByContainedInPlaceId({
392
+ project: { id: params.project.id },
393
+ containedInPlace: movieTheater
394
+ });
395
+ });
396
+ }
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.152"
120
+ "version": "21.2.0-alpha.153"
121
121
  }