@chevre/domain 21.4.0-alpha.10 → 21.4.0-alpha.12

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.
@@ -0,0 +1,32 @@
1
+ // tslint:disable:no-console
2
+ // import * as moment from 'moment';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ const project = { id: String(process.env.PROJECT_ID) };
8
+ const LOCATION_BRANCH_CODE = String(process.env.LOCATION_BRANCH_CODE);
9
+ // const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
10
+
11
+ // tslint:disable-next-line:max-func-body-length
12
+ async function main() {
13
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
+
15
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
16
+
17
+ let result = await eventRepo.deleteScreeningEventSeriesByMovieTheaterBranchCode({
18
+ project: { id: project.id },
19
+ location: { branchCode: LOCATION_BRANCH_CODE }
20
+ });
21
+ console.log('deleteScreeningEventSeriesByMovieTheaterBranchCode processed.', result);
22
+
23
+ result = await eventRepo.deleteScreeningEventsByMovieTheaterBranchCode({
24
+ project: { id: project.id },
25
+ location: { branchCode: LOCATION_BRANCH_CODE }
26
+ });
27
+ console.log('deleteScreeningEventsByMovieTheaterBranchCode processed.', result);
28
+ }
29
+
30
+ main()
31
+ .then()
32
+ .catch(console.error);
@@ -23,7 +23,8 @@ async function main() {
23
23
  chevre.factory.eventType.ScreeningEvent,
24
24
  chevre.factory.eventType.ScreeningEventSeries
25
25
  ]
26
- }
26
+ },
27
+ organizer: { $exists: false }
27
28
  // startDate: {
28
29
  // $gte: moment()
29
30
  // // tslint:disable-next-line:no-magic-numbers
@@ -62,12 +63,18 @@ async function main() {
62
63
  console.log('already exist...', event.project.id, event.id, event.startDate, organizerId, i);
63
64
  } else {
64
65
  let movieTheaterId: string;
66
+ let movieTheaterBranchCode: string;
65
67
  if (event.typeOf === chevre.factory.eventType.ScreeningEventSeries) {
66
68
  movieTheaterId = event.location.id;
69
+ movieTheaterBranchCode = event.location.branchCode;
67
70
  } else {
68
71
  movieTheaterId = event.superEvent.location.id;
72
+ movieTheaterBranchCode = event.superEvent.location.branchCode;
69
73
  }
70
- const movieTheaters = <Pick<chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom, 'parentOrganization'>[]>
74
+ const movieTheaters = <Pick<
75
+ chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom,
76
+ 'parentOrganization' | 'branchCode'
77
+ >[]>
71
78
  await placeRepo.searchMovieTheaters(
72
79
  {
73
80
  limit: 1,
@@ -75,12 +82,18 @@ async function main() {
75
82
  project: { id: { $eq: event.project.id } },
76
83
  id: { $eq: movieTheaterId }
77
84
  },
78
- ['parentOrganization'],
85
+ ['parentOrganization', 'branchCode'],
79
86
  []
80
87
  );
81
88
  const movieTheater = movieTheaters.shift();
82
89
  const sellerId = movieTheater?.parentOrganization?.id;
83
- console.log('movieTheater found', event.project.id, event.id, event.startDate, 'sellerId:', sellerId, i);
90
+ console.log(
91
+ 'movieTheater found',
92
+ event.project.id, event.id, event.startDate, 'sellerId:', sellerId,
93
+ 'movieTheaterId:', movieTheaterId,
94
+ 'movieTheaterBranchCode:', movieTheaterBranchCode,
95
+ i
96
+ );
84
97
  // if (typeof sellerId !== 'string') {
85
98
  // throw new Error('movieTheater not found');
86
99
  // }
@@ -0,0 +1,91 @@
1
+ // tslint:disable:no-console
2
+ // import * as moment from 'moment';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ // const project = { id: String(process.env.PROJECT_ID) };
8
+ // const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
9
+
10
+ // tslint:disable-next-line:max-func-body-length
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
13
+
14
+ const placeRepo = new chevre.repository.Place(mongoose.connection);
15
+
16
+ const cursor = placeRepo.getCursor(
17
+ {
18
+ // 'project.id': { $eq: project.id },
19
+ // 'project.id': { $ne: EXCLUDED_PROJECT_ID },
20
+ typeOf: {
21
+ $in: [
22
+ chevre.factory.placeType.ScreeningRoom
23
+ ]
24
+ }
25
+ // organizer: { $exists: false }
26
+ },
27
+ {
28
+ containsPlace: 0
29
+ }
30
+ );
31
+ console.log('places found');
32
+
33
+ let i = 0;
34
+ let updateCount = 0;
35
+ await cursor.eachAsync(async (doc) => {
36
+ i += 1;
37
+ const screeningRoom: chevre.factory.place.screeningRoom.IPlace = doc.toObject();
38
+ console.log(screeningRoom);
39
+
40
+ const organizerId = screeningRoom.parentOrganization?.id;
41
+ const alreadyMigrated = typeof organizerId === 'string';
42
+
43
+ if (alreadyMigrated) {
44
+ console.log('already exist...', screeningRoom.project.id, screeningRoom.branchCode, organizerId, i);
45
+ } else {
46
+ const movieTheaterId = screeningRoom.containedInPlace?.id;
47
+ if (typeof movieTheaterId !== 'string') {
48
+ throw new Error('containedInPlace?.id undefined');
49
+ }
50
+ const movieTheaters = <Pick<chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom, 'parentOrganization'>[]>
51
+ await placeRepo.searchMovieTheaters(
52
+ {
53
+ limit: 1,
54
+ page: 1,
55
+ project: { id: { $eq: screeningRoom.project.id } },
56
+ id: { $eq: movieTheaterId }
57
+ },
58
+ ['parentOrganization'],
59
+ []
60
+ );
61
+ const movieTheater = movieTheaters.shift();
62
+ const sellerId = movieTheater?.parentOrganization?.id;
63
+ console.log('movieTheater found', screeningRoom.project.id, screeningRoom.branchCode, 'sellerId:', sellerId, i);
64
+ // if (typeof sellerId !== 'string') {
65
+ // throw new Error('movieTheater not found');
66
+ // }
67
+ if (typeof sellerId === 'string') {
68
+ const newParentOrganization: chevre.factory.place.screeningRoom.IParentOrganization = {
69
+ id: sellerId,
70
+ typeOf: chevre.factory.organizationType.Corporation
71
+ };
72
+ console.log('updating room...', screeningRoom.project.id, screeningRoom.branchCode, i);
73
+ await placeRepo.addParentOrganization2ScreeningRoom({
74
+ project: screeningRoom.project,
75
+ branchCode: screeningRoom.branchCode,
76
+ containedInPlace: { branchCode: String(screeningRoom.containedInPlace?.branchCode) },
77
+ parentOrganization: newParentOrganization
78
+ });
79
+ updateCount += 1;
80
+ console.log('updated.', screeningRoom.project.id, screeningRoom.branchCode, i);
81
+ }
82
+ }
83
+ });
84
+
85
+ console.log(i, 'rooms checked');
86
+ console.log(updateCount, 'rooms updated');
87
+ }
88
+
89
+ main()
90
+ .then()
91
+ .catch(console.error);
@@ -169,6 +169,22 @@ export declare class MongoRepository {
169
169
  };
170
170
  id: string;
171
171
  }): Promise<void>;
172
+ deleteScreeningEventsByMovieTheaterBranchCode(params: {
173
+ project: {
174
+ id: string;
175
+ };
176
+ location: {
177
+ branchCode: string;
178
+ };
179
+ }): Promise<import("mongodb").DeleteResult>;
180
+ deleteScreeningEventSeriesByMovieTheaterBranchCode(params: {
181
+ project: {
182
+ id: string;
183
+ };
184
+ location: {
185
+ branchCode: string;
186
+ };
187
+ }): Promise<import("mongodb").DeleteResult>;
172
188
  deleteByProject(params: {
173
189
  project: {
174
190
  id: string;
@@ -850,6 +850,26 @@ class MongoRepository {
850
850
  .exec();
851
851
  });
852
852
  }
853
+ deleteScreeningEventsByMovieTheaterBranchCode(params) {
854
+ return __awaiter(this, void 0, void 0, function* () {
855
+ return this.eventModel.deleteMany({
856
+ typeOf: { $eq: factory.eventType.ScreeningEvent },
857
+ 'project.id': { $eq: params.project.id },
858
+ 'superEvent.location.branchCode': { $exists: true, $eq: params.location.branchCode }
859
+ })
860
+ .exec();
861
+ });
862
+ }
863
+ deleteScreeningEventSeriesByMovieTheaterBranchCode(params) {
864
+ return __awaiter(this, void 0, void 0, function* () {
865
+ return this.eventModel.deleteMany({
866
+ typeOf: { $eq: factory.eventType.ScreeningEventSeries },
867
+ 'project.id': { $eq: params.project.id },
868
+ 'location.branchCode': { $exists: true, $eq: params.location.branchCode }
869
+ })
870
+ .exec();
871
+ });
872
+ }
853
873
  deleteByProject(params) {
854
874
  return __awaiter(this, void 0, void 0, function* () {
855
875
  yield this.eventModel.deleteMany({
@@ -53,13 +53,14 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
53
53
  };
54
54
  }, {
55
55
  typeOf: string;
56
+ project: any;
56
57
  additionalProperty: any[];
58
+ parentOrganization: any;
57
59
  containsPlace: any[];
58
60
  hasEntranceGate: any[];
59
61
  hasPOS: any[];
60
62
  name?: any;
61
63
  url?: string | undefined;
62
- project?: any;
63
64
  alternateName?: any;
64
65
  description?: any;
65
66
  offers?: any;
@@ -72,18 +73,18 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
72
73
  openingHoursSpecification?: any;
73
74
  smokingAllowed?: boolean | undefined;
74
75
  sameAs?: string | undefined;
75
- parentOrganization?: any;
76
76
  openSeatingAllowed?: any;
77
77
  amenityFeature?: any;
78
78
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
79
79
  typeOf: string;
80
+ project: any;
80
81
  additionalProperty: any[];
82
+ parentOrganization: any;
81
83
  containsPlace: any[];
82
84
  hasEntranceGate: any[];
83
85
  hasPOS: any[];
84
86
  name?: any;
85
87
  url?: string | undefined;
86
- project?: any;
87
88
  alternateName?: any;
88
89
  description?: any;
89
90
  offers?: any;
@@ -96,18 +97,18 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
96
97
  openingHoursSpecification?: any;
97
98
  smokingAllowed?: boolean | undefined;
98
99
  sameAs?: string | undefined;
99
- parentOrganization?: any;
100
100
  openSeatingAllowed?: any;
101
101
  amenityFeature?: any;
102
102
  }>> & Omit<import("mongoose").FlatRecord<{
103
103
  typeOf: string;
104
+ project: any;
104
105
  additionalProperty: any[];
106
+ parentOrganization: any;
105
107
  containsPlace: any[];
106
108
  hasEntranceGate: any[];
107
109
  hasPOS: any[];
108
110
  name?: any;
109
111
  url?: string | undefined;
110
- project?: any;
111
112
  alternateName?: any;
112
113
  description?: any;
113
114
  offers?: any;
@@ -120,7 +121,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
120
121
  openingHoursSpecification?: any;
121
122
  smokingAllowed?: boolean | undefined;
122
123
  sameAs?: string | undefined;
123
- parentOrganization?: any;
124
124
  openSeatingAllowed?: any;
125
125
  amenityFeature?: any;
126
126
  }> & {
@@ -9,7 +9,15 @@ exports.modelName = modelName;
9
9
  * 場所スキーマ
10
10
  */
11
11
  const schema = new mongoose_1.Schema({
12
- project: mongoose_1.SchemaTypes.Mixed,
12
+ project: {
13
+ type: mongoose_1.SchemaTypes.Mixed,
14
+ required: true
15
+ },
16
+ // 必須化(2023-07-14~)
17
+ parentOrganization: {
18
+ type: mongoose_1.SchemaTypes.Mixed,
19
+ required: true
20
+ },
13
21
  typeOf: {
14
22
  type: String,
15
23
  required: true
@@ -32,7 +40,6 @@ const schema = new mongoose_1.Schema({
32
40
  kanaName: String,
33
41
  offers: mongoose_1.SchemaTypes.Mixed,
34
42
  additionalProperty: [mongoose_1.SchemaTypes.Mixed],
35
- parentOrganization: mongoose_1.SchemaTypes.Mixed,
36
43
  // ↓ルームの施設からの分離に伴い属性追加(2023-06-22~)
37
44
  openSeatingAllowed: mongoose_1.SchemaTypes.Mixed,
38
45
  amenityFeature: mongoose_1.SchemaTypes.Mixed
@@ -25,7 +25,7 @@
25
25
  import { Connection } from 'mongoose';
26
26
  import * as factory from '../factory';
27
27
  type IScreeningRoomSectionWithoutContainsPlace = Omit<factory.place.screeningRoomSection.IPlace, 'containsPlace'>;
28
- export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount'>;
28
+ export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
29
29
  /**
30
30
  * 施設リポジトリ
31
31
  */
@@ -44,9 +44,12 @@ export declare class MongoRepository {
44
44
  */
45
45
  searchMovieTheaters(params: factory.place.movieTheater.ISearchConditions & {}, inclusion: string[], exclusion: string[]): Promise<factory.place.movieTheater.IPlaceWithoutScreeningRoom[]>;
46
46
  deleteMovieTheaterById(params: {
47
+ project: {
48
+ id: string;
49
+ };
47
50
  id: string;
48
51
  }): Promise<void>;
49
- createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace'> & {
52
+ createScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
50
53
  containedInPlace: {
51
54
  branchCode: string;
52
55
  };
@@ -59,7 +62,7 @@ export declare class MongoRepository {
59
62
  };
60
63
  typeOf: factory.placeType.ScreeningRoom;
61
64
  }>;
62
- updateScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace'> & {
65
+ updateScreeningRoom(screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containedInPlace' | 'containsPlace' | 'parentOrganization'> & {
63
66
  containedInPlace: {
64
67
  branchCode: string;
65
68
  };
@@ -72,6 +75,19 @@ export declare class MongoRepository {
72
75
  };
73
76
  typeOf: factory.placeType.ScreeningRoom;
74
77
  }>;
78
+ addParentOrganization2ScreeningRoom(screeningRoom: Pick<factory.place.screeningRoom.IPlace, 'branchCode' | 'parentOrganization' | 'project'> & {
79
+ containedInPlace: {
80
+ branchCode: string;
81
+ };
82
+ }): Promise<{
83
+ containedInPlace: {
84
+ /**
85
+ * 施設ID
86
+ */
87
+ id: string;
88
+ };
89
+ typeOf: factory.placeType.ScreeningRoom;
90
+ }>;
75
91
  updateScreeningRoomsByContainedInPlaceId(screeningRoom: {
76
92
  project: {
77
93
  id: string;
@@ -171,8 +187,11 @@ export declare class MongoRepository {
171
187
  };
172
188
  typeOf: factory.placeType.ScreeningRoom;
173
189
  }>;
174
- searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace'>[]>;
190
+ searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace' | 'parentOrganization'>[]>;
175
191
  findScreeningRoomsByBranchCode(params: {
192
+ project: {
193
+ id: string;
194
+ };
176
195
  branchCode: {
177
196
  $eq: string;
178
197
  };
@@ -246,16 +265,6 @@ export declare class MongoRepository {
246
265
  };
247
266
  typeOf: factory.placeType.ScreeningRoom;
248
267
  }>;
249
- syncScreeningRooms(__: {
250
- /**
251
- * 施設ID
252
- */
253
- id: string;
254
- /**
255
- * 特定のルームのみ同期する場合、ルームコードを指定する
256
- */
257
- screeningRoomBranchCode?: string;
258
- }): Promise<void>;
259
268
  unsetContainsPlaceFromMovieTheater(params: {
260
269
  /**
261
270
  * 施設ID
@@ -281,6 +290,9 @@ export declare class MongoRepository {
281
290
  id: string;
282
291
  }, projection?: any): Promise<factory.place.busStop.IPlace>;
283
292
  deleteBusStopById(params: {
293
+ project: {
294
+ id: string;
295
+ };
284
296
  id: string;
285
297
  }): Promise<void>;
286
298
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
@@ -342,7 +342,8 @@ class MongoRepository {
342
342
  return __awaiter(this, void 0, void 0, function* () {
343
343
  yield this.placeModel.findOneAndDelete({
344
344
  typeOf: { $eq: factory.placeType.MovieTheater },
345
- _id: { $eq: params.id }
345
+ _id: { $eq: params.id },
346
+ 'project.id': { $eq: params.project.id }
346
347
  }, { projection: { _id: 1 } })
347
348
  .exec()
348
349
  .then((doc) => {
@@ -359,7 +360,7 @@ class MongoRepository {
359
360
  typeOf: { $eq: factory.placeType.MovieTheater },
360
361
  'project.id': { $eq: screeningRoom.project.id },
361
362
  branchCode: { $eq: screeningRoom.containedInPlace.branchCode }
362
- }, { _id: 1, typeOf: 1, branchCode: 1, name: 1 })
363
+ }, { _id: 1, typeOf: 1, branchCode: 1, name: 1, parentOrganization: 1 })
363
364
  .exec();
364
365
  if (movieTheaterDoc === null) {
365
366
  throw new factory.errors.NotFound(factory.placeType.MovieTheater);
@@ -370,7 +371,9 @@ class MongoRepository {
370
371
  typeOf: movieTheater.typeOf,
371
372
  branchCode: movieTheater.branchCode,
372
373
  name: movieTheater.name
373
- }, containsPlace: [], project: screeningRoom.project }, (typeof screeningRoom.openSeatingAllowed === 'boolean')
374
+ }, containsPlace: [], project: screeningRoom.project,
375
+ // 必須化(2023-07-14~)
376
+ parentOrganization: movieTheater.parentOrganization }, (typeof screeningRoom.openSeatingAllowed === 'boolean')
374
377
  ? { openSeatingAllowed: screeningRoom.openSeatingAllowed }
375
378
  : undefined);
376
379
  const upsertScreeningRoomResult = yield this.placeModel.updateOne({
@@ -423,6 +426,26 @@ class MongoRepository {
423
426
  return doc.toObject();
424
427
  });
425
428
  }
429
+ addParentOrganization2ScreeningRoom(screeningRoom) {
430
+ return __awaiter(this, void 0, void 0, function* () {
431
+ const doc = yield this.placeModel.findOneAndUpdate({
432
+ typeOf: { $eq: factory.placeType.ScreeningRoom },
433
+ 'project.id': { $eq: screeningRoom.project.id },
434
+ 'containedInPlace.branchCode': { $exists: true, $eq: screeningRoom.containedInPlace.branchCode },
435
+ branchCode: screeningRoom.branchCode
436
+ }, {
437
+ parentOrganization: screeningRoom.parentOrganization
438
+ }, {
439
+ new: true,
440
+ projection: { 'containedInPlace.id': 1, typeOf: 1 }
441
+ })
442
+ .exec();
443
+ if (doc === null) {
444
+ throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
445
+ }
446
+ return doc.toObject();
447
+ });
448
+ }
426
449
  updateScreeningRoomsByContainedInPlaceId(screeningRoom) {
427
450
  var _a;
428
451
  return __awaiter(this, void 0, void 0, function* () {
@@ -558,7 +581,7 @@ class MongoRepository {
558
581
  }
559
582
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
560
583
  searchScreeningRoomSections(searchConditions) {
561
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
584
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
562
585
  return __awaiter(this, void 0, void 0, function* () {
563
586
  const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
564
587
  const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
@@ -567,8 +590,14 @@ class MongoRepository {
567
590
  $match: { 'project.id': { $eq: projectIdEq } }
568
591
  });
569
592
  }
593
+ const parentOrganizationIdEq = (_d = (_c = searchConditions.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
594
+ if (typeof parentOrganizationIdEq === 'string') {
595
+ matchStages.push({
596
+ $match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
597
+ });
598
+ }
570
599
  // 施設コード
571
- const movieTheaterBranchCodeEq = (_e = (_d = (_c = searchConditions.containedInPlace) === null || _c === void 0 ? void 0 : _c.containedInPlace) === null || _d === void 0 ? void 0 : _d.branchCode) === null || _e === void 0 ? void 0 : _e.$eq;
600
+ const movieTheaterBranchCodeEq = (_g = (_f = (_e = searchConditions.containedInPlace) === null || _e === void 0 ? void 0 : _e.containedInPlace) === null || _f === void 0 ? void 0 : _f.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
572
601
  if (typeof movieTheaterBranchCodeEq === 'string') {
573
602
  matchStages.push({
574
603
  $match: {
@@ -580,7 +609,7 @@ class MongoRepository {
580
609
  });
581
610
  }
582
611
  // ルームコード
583
- const containedInPlaceBranchCodeEq = (_g = (_f = searchConditions.containedInPlace) === null || _f === void 0 ? void 0 : _f.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
612
+ const containedInPlaceBranchCodeEq = (_j = (_h = searchConditions.containedInPlace) === null || _h === void 0 ? void 0 : _h.branchCode) === null || _j === void 0 ? void 0 : _j.$eq;
584
613
  if (typeof containedInPlaceBranchCodeEq === 'string') {
585
614
  matchStages.push({
586
615
  $match: {
@@ -591,7 +620,7 @@ class MongoRepository {
591
620
  });
592
621
  }
593
622
  // セクションコード
594
- const sectionBranchCodeEq = (_h = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _h === void 0 ? void 0 : _h.$eq;
623
+ const sectionBranchCodeEq = (_k = searchConditions === null || searchConditions === void 0 ? void 0 : searchConditions.branchCode) === null || _k === void 0 ? void 0 : _k.$eq;
595
624
  if (typeof sectionBranchCodeEq === 'string') {
596
625
  matchStages.push({
597
626
  $match: {
@@ -602,7 +631,7 @@ class MongoRepository {
602
631
  }
603
632
  });
604
633
  }
605
- const nameCodeRegex = (_j = searchConditions.name) === null || _j === void 0 ? void 0 : _j.$regex;
634
+ const nameCodeRegex = (_l = searchConditions.name) === null || _l === void 0 ? void 0 : _l.$regex;
606
635
  if (typeof nameCodeRegex === 'string') {
607
636
  matchStages.push({
608
637
  $match: {
@@ -623,7 +652,7 @@ class MongoRepository {
623
652
  }
624
653
  });
625
654
  }
626
- const branchCodeRegex = (_k = searchConditions.branchCode) === null || _k === void 0 ? void 0 : _k.$regex;
655
+ const branchCodeRegex = (_m = searchConditions.branchCode) === null || _m === void 0 ? void 0 : _m.$regex;
627
656
  if (typeof branchCodeRegex === 'string') {
628
657
  matchStages.push({
629
658
  $match: {
@@ -634,7 +663,7 @@ class MongoRepository {
634
663
  }
635
664
  });
636
665
  }
637
- const additionalPropertyElemMatch = (_l = searchConditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
666
+ const additionalPropertyElemMatch = (_o = searchConditions.additionalProperty) === null || _o === void 0 ? void 0 : _o.$elemMatch;
638
667
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
639
668
  matchStages.push({
640
669
  $match: {
@@ -659,7 +688,7 @@ class MongoRepository {
659
688
  branchCode: '$containedInPlace.branchCode',
660
689
  name: '$containedInPlace.name'
661
690
  }
662
- }, additionalProperty: '$containsPlace.additionalProperty' }, (((_m = searchConditions.$projection) === null || _m === void 0 ? void 0 : _m.seatCount) === 1)
691
+ }, additionalProperty: '$containsPlace.additionalProperty' }, (((_p = searchConditions.$projection) === null || _p === void 0 ? void 0 : _p.seatCount) === 1)
663
692
  ? {
664
693
  seatCount: {
665
694
  $cond: {
@@ -712,7 +741,7 @@ class MongoRepository {
712
741
  }
713
742
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
714
743
  searchScreeningRooms(searchConditions) {
715
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
744
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
716
745
  return __awaiter(this, void 0, void 0, function* () {
717
746
  const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
718
747
  const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
@@ -721,8 +750,14 @@ class MongoRepository {
721
750
  $match: { 'project.id': { $eq: projectIdEq } }
722
751
  });
723
752
  }
753
+ const parentOrganizationIdEq = (_d = (_c = searchConditions.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
754
+ if (typeof parentOrganizationIdEq === 'string') {
755
+ matchStages.push({
756
+ $match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
757
+ });
758
+ }
724
759
  // 施設ID
725
- const containedInPlaceIdEq = (_d = (_c = searchConditions.containedInPlace) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
760
+ const containedInPlaceIdEq = (_f = (_e = searchConditions.containedInPlace) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
726
761
  if (typeof containedInPlaceIdEq === 'string') {
727
762
  matchStages.push({
728
763
  $match: {
@@ -748,7 +783,7 @@ class MongoRepository {
748
783
  }
749
784
  }
750
785
  }
751
- const branchCodeEq = (_e = searchConditions.branchCode) === null || _e === void 0 ? void 0 : _e.$eq;
786
+ const branchCodeEq = (_g = searchConditions.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
752
787
  if (typeof branchCodeEq === 'string') {
753
788
  matchStages.push({
754
789
  $match: {
@@ -756,7 +791,7 @@ class MongoRepository {
756
791
  }
757
792
  });
758
793
  }
759
- const branchCodeIn = (_f = searchConditions.branchCode) === null || _f === void 0 ? void 0 : _f.$in;
794
+ const branchCodeIn = (_h = searchConditions.branchCode) === null || _h === void 0 ? void 0 : _h.$in;
760
795
  if (Array.isArray(branchCodeIn)) {
761
796
  matchStages.push({
762
797
  $match: {
@@ -764,7 +799,7 @@ class MongoRepository {
764
799
  }
765
800
  });
766
801
  }
767
- const branchCodeRegex = (_g = searchConditions.branchCode) === null || _g === void 0 ? void 0 : _g.$regex;
802
+ const branchCodeRegex = (_j = searchConditions.branchCode) === null || _j === void 0 ? void 0 : _j.$regex;
768
803
  if (typeof branchCodeRegex === 'string') {
769
804
  matchStages.push({
770
805
  $match: {
@@ -774,7 +809,7 @@ class MongoRepository {
774
809
  }
775
810
  });
776
811
  }
777
- const nameCodeRegex = (_h = searchConditions.name) === null || _h === void 0 ? void 0 : _h.$regex;
812
+ const nameCodeRegex = (_k = searchConditions.name) === null || _k === void 0 ? void 0 : _k.$regex;
778
813
  if (typeof nameCodeRegex === 'string') {
779
814
  matchStages.push({
780
815
  $match: {
@@ -806,7 +841,7 @@ class MongoRepository {
806
841
  }
807
842
  });
808
843
  }
809
- const additionalPropertyElemMatch = (_j = searchConditions.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
844
+ const additionalPropertyElemMatch = (_l = searchConditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
810
845
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
811
846
  matchStages.push({
812
847
  $match: {
@@ -827,7 +862,7 @@ class MongoRepository {
827
862
  typeOf: '$containedInPlace.typeOf',
828
863
  branchCode: '$containedInPlace.branchCode',
829
864
  name: '$containedInPlace.name'
830
- }, openSeatingAllowed: '$openSeatingAllowed', additionalProperty: '$additionalProperty', maximumAttendeeCapacity: '$maximumAttendeeCapacity' }, (((_k = searchConditions.$projection) === null || _k === void 0 ? void 0 : _k.sectionCount) === 1)
865
+ }, openSeatingAllowed: '$openSeatingAllowed', additionalProperty: '$additionalProperty', maximumAttendeeCapacity: '$maximumAttendeeCapacity' }, (((_m = searchConditions.$projection) === null || _m === void 0 ? void 0 : _m.sectionCount) === 1)
831
866
  ? {
832
867
  sectionCount: {
833
868
  $cond: {
@@ -837,7 +872,7 @@ class MongoRepository {
837
872
  }
838
873
  }
839
874
  }
840
- : undefined), (((_l = searchConditions.$projection) === null || _l === void 0 ? void 0 : _l.seatCount) === 1)
875
+ : undefined), (((_o = searchConditions.$projection) === null || _o === void 0 ? void 0 : _o.seatCount) === 1)
841
876
  ? {
842
877
  seatCount: {
843
878
  $sum: {
@@ -871,12 +906,9 @@ class MongoRepository {
871
906
  return __awaiter(this, void 0, void 0, function* () {
872
907
  const matchStages = [
873
908
  { $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } },
874
- {
875
- $match: { 'containedInPlace.id': { $exists: true, $eq: params.containedInPlace.id.$eq } }
876
- },
877
- {
878
- $match: { branchCode: { $eq: params.branchCode.$eq } }
879
- }
909
+ { $match: { 'project.id': { $eq: params.project.id } } },
910
+ { $match: { 'containedInPlace.id': { $exists: true, $eq: params.containedInPlace.id.$eq } } },
911
+ { $match: { branchCode: { $eq: params.branchCode.$eq } } }
880
912
  ];
881
913
  const aggregate = this.placeModel.aggregate([
882
914
  // { $unwind: '$containsPlace' },
@@ -1031,7 +1063,7 @@ class MongoRepository {
1031
1063
  }
1032
1064
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
1033
1065
  searchSeats(params) {
1034
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1066
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
1035
1067
  return __awaiter(this, void 0, void 0, function* () {
1036
1068
  const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
1037
1069
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
@@ -1040,7 +1072,13 @@ class MongoRepository {
1040
1072
  $match: { 'project.id': { $eq: projectIdEq } }
1041
1073
  });
1042
1074
  }
1043
- const containedInPlaceBranchCodeEq = (_d = (_c = params.containedInPlace) === null || _c === void 0 ? void 0 : _c.branchCode) === null || _d === void 0 ? void 0 : _d.$eq;
1075
+ const parentOrganizationIdEq = (_d = (_c = params.parentOrganization) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
1076
+ if (typeof parentOrganizationIdEq === 'string') {
1077
+ matchStages.push({
1078
+ $match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
1079
+ });
1080
+ }
1081
+ const containedInPlaceBranchCodeEq = (_f = (_e = params.containedInPlace) === null || _e === void 0 ? void 0 : _e.branchCode) === null || _f === void 0 ? void 0 : _f.$eq;
1044
1082
  if (typeof containedInPlaceBranchCodeEq === 'string') {
1045
1083
  matchStages.push({
1046
1084
  $match: {
@@ -1051,7 +1089,7 @@ class MongoRepository {
1051
1089
  }
1052
1090
  });
1053
1091
  }
1054
- const containedInPlaceBranchCodeIn = (_f = (_e = params.containedInPlace) === null || _e === void 0 ? void 0 : _e.branchCode) === null || _f === void 0 ? void 0 : _f.$in;
1092
+ const containedInPlaceBranchCodeIn = (_h = (_g = params.containedInPlace) === null || _g === void 0 ? void 0 : _g.branchCode) === null || _h === void 0 ? void 0 : _h.$in;
1055
1093
  if (Array.isArray(containedInPlaceBranchCodeIn)) {
1056
1094
  matchStages.push({
1057
1095
  $match: {
@@ -1104,7 +1142,7 @@ class MongoRepository {
1104
1142
  });
1105
1143
  }
1106
1144
  }
1107
- const branchCodeIn = (_g = params.branchCode) === null || _g === void 0 ? void 0 : _g.$in;
1145
+ const branchCodeIn = (_j = params.branchCode) === null || _j === void 0 ? void 0 : _j.$in;
1108
1146
  if (Array.isArray(branchCodeIn)) {
1109
1147
  matchStages.push({
1110
1148
  $match: {
@@ -1115,7 +1153,7 @@ class MongoRepository {
1115
1153
  }
1116
1154
  });
1117
1155
  }
1118
- const branchCodeRegex = (_h = params.branchCode) === null || _h === void 0 ? void 0 : _h.$regex;
1156
+ const branchCodeRegex = (_k = params.branchCode) === null || _k === void 0 ? void 0 : _k.$regex;
1119
1157
  if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
1120
1158
  matchStages.push({
1121
1159
  $match: {
@@ -1126,7 +1164,7 @@ class MongoRepository {
1126
1164
  }
1127
1165
  });
1128
1166
  }
1129
- const nameRegex = (_j = params.name) === null || _j === void 0 ? void 0 : _j.$regex;
1167
+ const nameRegex = (_l = params.name) === null || _l === void 0 ? void 0 : _l.$regex;
1130
1168
  if (typeof nameRegex === 'string' && nameRegex.length > 0) {
1131
1169
  matchStages.push({
1132
1170
  $match: {
@@ -1147,7 +1185,7 @@ class MongoRepository {
1147
1185
  }
1148
1186
  });
1149
1187
  }
1150
- const seatingTypeEq = (_k = params.seatingType) === null || _k === void 0 ? void 0 : _k.$eq;
1188
+ const seatingTypeEq = (_m = params.seatingType) === null || _m === void 0 ? void 0 : _m.$eq;
1151
1189
  if (typeof seatingTypeEq === 'string') {
1152
1190
  matchStages.push({
1153
1191
  $match: {
@@ -1163,7 +1201,7 @@ class MongoRepository {
1163
1201
  && params.$projection['containedInPlace.containedInPlace'] === 0) {
1164
1202
  includeScreeningRooms = false;
1165
1203
  }
1166
- const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
1204
+ const additionalPropertyElemMatch = (_o = params.additionalProperty) === null || _o === void 0 ? void 0 : _o.$elemMatch;
1167
1205
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
1168
1206
  matchStages.push({
1169
1207
  $match: {
@@ -1245,77 +1283,6 @@ class MongoRepository {
1245
1283
  return doc.toObject();
1246
1284
  });
1247
1285
  }
1248
- // tslint:disable-next-line:prefer-function-over-method
1249
- syncScreeningRooms(__) {
1250
- return __awaiter(this, void 0, void 0, function* () {
1251
- return;
1252
- // const movieTheater = <Pick<
1253
- // factory.place.movieTheater.IPlace,
1254
- // 'id' | 'branchCode' | 'name' | 'project' | 'typeOf' | 'containsPlace'
1255
- // >>await this.placeModel.findOne({
1256
- // _id: { $eq: params.id },
1257
- // typeOf: { $eq: factory.placeType.MovieTheater }
1258
- // })
1259
- // .select({
1260
- // _id: 1, branchCode: 1, name: 1, project: 1, typeOf: 1, containsPlace: 1
1261
- // })
1262
- // .exec()
1263
- // .then((doc) => {
1264
- // if (doc === null) {
1265
- // throw new factory.errors.NotFound(factory.placeType.MovieTheater);
1266
- // }
1267
- // return doc.toObject();
1268
- // });
1269
- // let screeningRoomsFromMovieTheater = movieTheater.containsPlace;
1270
- // if (typeof params.screeningRoomBranchCode === 'string' && params.screeningRoomBranchCode.length > 0) {
1271
- // screeningRoomsFromMovieTheater = screeningRoomsFromMovieTheater.filter(
1272
- // (place) => place.branchCode === params.screeningRoomBranchCode
1273
- // );
1274
- // }
1275
- // const creatingScreeningRooms: ICreatingScreeningRoom[] = screeningRoomsFromMovieTheater.map((place) => {
1276
- // return {
1277
- // ...place,
1278
- // containedInPlace: {
1279
- // id: movieTheater.id,
1280
- // typeOf: movieTheater.typeOf,
1281
- // branchCode: movieTheater.branchCode,
1282
- // name: movieTheater.name
1283
- // },
1284
- // containsPlace: (Array.isArray(place.containsPlace)) ? place.containsPlace : [],
1285
- // project: movieTheater.project
1286
- // };
1287
- // });
1288
- // debug('sync processing', creatingScreeningRooms.length, 'screeningRooms...', creatingScreeningRooms);
1289
- // await Promise.all(creatingScreeningRooms.map(async (createScreeningRoom) => {
1290
- // const { typeOf, project, branchCode, ...setFields } = createScreeningRoom;
1291
- // if (typeof branchCode === 'string' && branchCode.length > 0) {
1292
- // const upsertScreeningRoomResult = await this.placeModel.findOneAndUpdate(
1293
- // {
1294
- // typeOf: { $eq: factory.placeType.ScreeningRoom },
1295
- // 'project.id': { $eq: createScreeningRoom.project.id },
1296
- // 'containedInPlace.id': { $exists: true, $eq: createScreeningRoom.containedInPlace.id },
1297
- // branchCode: { $eq: createScreeningRoom.branchCode }
1298
- // },
1299
- // {
1300
- // $setOnInsert: {
1301
- // typeOf: createScreeningRoom.typeOf,
1302
- // project: createScreeningRoom.project,
1303
- // branchCode: createScreeningRoom.branchCode
1304
- // },
1305
- // $set: setFields
1306
- // },
1307
- // {
1308
- // upsert: true,
1309
- // new: true,
1310
- // projection: { _id: 1 }
1311
- // }
1312
- // )
1313
- // .exec();
1314
- // debug('screeningRoom upserted. upsertScreeningRoomResult:', upsertScreeningRoomResult);
1315
- // }
1316
- // }));
1317
- });
1318
- }
1319
1286
  unsetContainsPlaceFromMovieTheater(params) {
1320
1287
  return __awaiter(this, void 0, void 0, function* () {
1321
1288
  return this.placeModel.findOneAndUpdate({
@@ -1420,7 +1387,8 @@ class MongoRepository {
1420
1387
  return __awaiter(this, void 0, void 0, function* () {
1421
1388
  yield this.placeModel.findOneAndDelete({
1422
1389
  typeOf: { $eq: factory.placeType.BusStop },
1423
- _id: { $eq: params.id }
1390
+ _id: { $eq: params.id },
1391
+ 'project.id': { $eq: params.project.id }
1424
1392
  })
1425
1393
  .exec()
1426
1394
  .then((doc) => {
@@ -80,6 +80,7 @@ function aggregateByEvent(params) {
80
80
  movieTheaterId = String((_a = params.event.offers) === null || _a === void 0 ? void 0 : _a.itemOffered.availableChannel.serviceLocation.containedInPlace.id);
81
81
  }
82
82
  const screeningRoom = yield repos.place.findScreeningRoomsByBranchCode({
83
+ project: { id: event.project.id },
83
84
  branchCode: { $eq: event.location.branchCode },
84
85
  containedInPlace: { id: { $eq: movieTheaterId } }
85
86
  });
@@ -670,7 +670,7 @@ function createMovieTheaterFromCOA(project, seller, theaterFromCOA, screensFromC
670
670
  },
671
671
  kanaName: theaterFromCOA.theaterNameKana,
672
672
  containsPlace: screensFromCOA.map((screenFromCOA) => {
673
- return createScreeningRoomFromCOA(project, screenFromCOA);
673
+ return createScreeningRoomFromCOA(project, seller, screenFromCOA);
674
674
  }),
675
675
  typeOf: factory.placeType.MovieTheater,
676
676
  telephone: theaterFromCOA.theaterTelNum,
@@ -712,7 +712,7 @@ function createMovieTheaterFromCOA(project, seller, theaterFromCOA, screensFromC
712
712
  */
713
713
  // tslint:disable-next-line:no-single-line-block-comment
714
714
  /* istanbul ignore next */
715
- function createScreeningRoomFromCOA(project, screenFromCOA) {
715
+ function createScreeningRoomFromCOA(project, seller, screenFromCOA) {
716
716
  const sections = [];
717
717
  const sectionCodes = [];
718
718
  screenFromCOA.listSeat.forEach((seat) => {
@@ -751,7 +751,9 @@ function createScreeningRoomFromCOA(project, screenFromCOA) {
751
751
  en: screenFromCOA.screenNameEng
752
752
  },
753
753
  typeOf: factory.placeType.ScreeningRoom,
754
- maximumAttendeeCapacity: sections[0].containsPlace.length
754
+ maximumAttendeeCapacity: sections[0].containsPlace.length,
755
+ // 必須化(2023-07-14~)
756
+ parentOrganization: { id: seller.id, typeOf: factory.organizationType.Corporation }
755
757
  };
756
758
  }
757
759
  function updateEvent4ttts(params) {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.315.0-alpha.2",
12
+ "@chevre/factory": "4.315.0-alpha.3",
13
13
  "@cinerino/sdk": "3.160.0-alpha.3",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -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.4.0-alpha.10"
120
+ "version": "21.4.0-alpha.12"
121
121
  }
@@ -1,27 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- async function main() {
7
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
-
9
- const placeRepo = new chevre.repository.Place(mongoose.connection);
10
-
11
- const screeningRoom = await placeRepo.findScreeningRoomsByBranchCode({
12
- branchCode: {
13
- $eq: '20'
14
- },
15
- containedInPlace: {
16
- id: {
17
- $eq: '5bfb841d5a78d7948369979a'
18
- }
19
- }
20
- });
21
- console.log('room found', screeningRoom);
22
-
23
- }
24
-
25
- main()
26
- .then(console.log)
27
- .catch(console.error);
@@ -1,33 +0,0 @@
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
-
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
-
11
- const placeRepo = new chevre.repository.Place(mongoose.connection);
12
-
13
- const rooms = await placeRepo.searchScreeningRooms(
14
- {
15
- limit: 10,
16
- page: 1,
17
- $projection: { sectionCount: 1 }
18
- }
19
- );
20
- console.log('place found', rooms);
21
- const filteredRooms = rooms.filter((room) => typeof room.sectionCount === 'number' && room.sectionCount > 1);
22
- console.log(filteredRooms.length, 'filteredRooms found');
23
-
24
- const screeningRoom = await placeRepo.findScreeningRoomsByBranchCode({
25
- branchCode: { $eq: rooms[0].branchCode },
26
- containedInPlace: { id: { $eq: String(rooms[0].containedInPlace?.id) } }
27
- });
28
- console.log('screeningRoom found', screeningRoom);
29
- }
30
-
31
- main()
32
- .then(console.log)
33
- .catch(console.error);
@@ -1,21 +0,0 @@
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
-
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
-
11
- const placeRepo = new chevre.repository.Place(mongoose.connection);
12
-
13
- await placeRepo.syncScreeningRooms({
14
- id: '60409176f60a46000a7a3787'
15
- });
16
- console.log('synced');
17
- }
18
-
19
- main()
20
- .then(console.log)
21
- .catch(console.error);
@@ -1,41 +0,0 @@
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
-
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
-
11
- const placeRepo = new chevre.repository.Place(mongoose.connection);
12
-
13
- const cursor = placeRepo.getCursor(
14
- {
15
- typeOf: { $eq: chevre.factory.placeType.MovieTheater }
16
- },
17
- {
18
- _id: 1,
19
- name: 1,
20
- project: 1,
21
- typeOf: 1
22
- }
23
- );
24
- console.log('places found');
25
-
26
- let i = 0;
27
- await cursor.eachAsync(async (doc) => {
28
- i += 1;
29
- const { id, name, project, typeOf } = <Pick<chevre.factory.place.movieTheater.IPlace, 'id' | 'name' | 'project' | 'typeOf'>>
30
- doc.toObject();
31
-
32
- console.log('syncing...', project.id, typeOf, id, name.ja, i);
33
- await placeRepo.syncScreeningRooms({ id });
34
- console.log('synced.', project.id, typeOf, id, name.ja, i);
35
- });
36
-
37
- }
38
-
39
- main()
40
- .then(console.log)
41
- .catch(console.error);
@@ -1,7 +0,0 @@
1
- import * as factory from '../../factory';
2
- import { IConnectionSettings } from '../task';
3
- export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
4
- /**
5
- * タスク実行関数
6
- */
7
- export declare function call(data: factory.task.syncScreeningRooms.IData): IOperation<void>;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.call = void 0;
13
- const place_1 = require("../../repo/place");
14
- /**
15
- * タスク実行関数
16
- */
17
- function call(data) {
18
- return (connectionSettings) => __awaiter(this, void 0, void 0, function* () {
19
- const placeRepo = new place_1.MongoRepository(connectionSettings.connection);
20
- yield placeRepo.syncScreeningRooms({ id: data.id });
21
- });
22
- }
23
- exports.call = call;