@chevre/domain 23.1.0-alpha.30 → 23.1.0-alpha.31

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,27 @@
1
+ // tslint:disable:no-console no-magic-numbers
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ // tslint:disable-next-line:max-func-body-length
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const roomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
11
+
12
+ const rooms = await roomRepo.searchScreeningRooms({
13
+ $projection: { sectionCount: 1 }
14
+ });
15
+ console.log('docs found');
16
+ console.log(rooms);
17
+
18
+ const mutipleSectionRooms = rooms.filter((room) => typeof room.sectionCount === 'number' && room.sectionCount > 1);
19
+ console.log(mutipleSectionRooms);
20
+
21
+ console.log(rooms.length, 'rooms');
22
+ console.log(mutipleSectionRooms.length, 'mutipleSectionRooms');
23
+ }
24
+
25
+ main()
26
+ .then()
27
+ .catch(console.error);
@@ -0,0 +1,50 @@
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
+ const SCREEN_CODE = '100';
8
+ const MOVIE_THEATER_CODE = '118';
9
+ const SELLER_ID = '59d20831e53ebc2b4e774466';
10
+
11
+ const formatter = new Intl.NumberFormat('ja-JP');
12
+
13
+ // tslint:disable-next-line:max-func-body-length
14
+ async function main() {
15
+ let startTime: [number, number] = process.hrtime();
16
+ let diff: [number, number] = process.hrtime(startTime);
17
+
18
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
19
+
20
+ const sectionRepo = await chevre.repository.place.Section.createInstance(mongoose.connection);
21
+
22
+ setInterval(
23
+ async () => {
24
+ startTime = process.hrtime();
25
+ const seats = await sectionRepo.findSectionsByRoom(
26
+ {
27
+ limit: 10,
28
+ page: 1,
29
+ projectId: PROJECT_ID,
30
+ sellerId: SELLER_ID,
31
+ movieTheaterCode: MOVIE_THEATER_CODE,
32
+ roomCode: SCREEN_CODE
33
+ }
34
+ );
35
+ diff = process.hrtime(startTime);
36
+ // tslint:disable-next-line:no-null-keyword
37
+ console.dir(seats, { depth: null });
38
+ console.log(seats.length, 'sections found');
39
+ console.log('diff:', [diff[0], formatter.format(diff[1])]);
40
+ },
41
+ // tslint:disable-next-line:no-magic-numbers
42
+ 1000
43
+ );
44
+ }
45
+
46
+ main()
47
+ .then(() => {
48
+ console.log('success!');
49
+ })
50
+ .catch(console.error);
@@ -37,6 +37,26 @@ export declare class SectionRepo {
37
37
  };
38
38
  }, $unset: any): Promise<IUpdateSectionResult>;
39
39
  searchScreeningRoomSections(searchConditions: factory.place.screeningRoomSection.ISearchConditions): Promise<IScreeningRoomSectionWithoutContainsPlace[]>;
40
+ /**
41
+ * ルーム指定のセクション検索として再定義(2025-12-07~)
42
+ */
43
+ findSectionsByRoom(params: {
44
+ limit: number;
45
+ page: number;
46
+ projectId: string;
47
+ /**
48
+ * 販売者ID
49
+ */
50
+ sellerId: string;
51
+ /**
52
+ * 施設コード
53
+ */
54
+ movieTheaterCode: string;
55
+ /**
56
+ * ルームコード
57
+ */
58
+ roomCode: string;
59
+ }): Promise<Pick<IScreeningRoomSectionWithoutContainsPlace, 'additionalProperty' | 'branchCode' | 'name'>[]>;
40
60
  deleteScreeningRoomSection(screeningRoomSection: {
41
61
  project: {
42
62
  id: string;
@@ -248,6 +248,53 @@ class SectionRepo {
248
248
  .exec();
249
249
  });
250
250
  }
251
+ /**
252
+ * ルーム指定のセクション検索として再定義(2025-12-07~)
253
+ */
254
+ findSectionsByRoom(params
255
+ // options: Pick<
256
+ // factory.place.screeningRoomSection.ISearchConditions,
257
+ // 'branchCode'
258
+ // >
259
+ ) {
260
+ return __awaiter(this, void 0, void 0, function* () {
261
+ const { limit, page, projectId, sellerId, movieTheaterCode, roomCode } = params;
262
+ const matchStageBeforeUnwind = {
263
+ $match: {
264
+ 'project.id': { $eq: projectId },
265
+ 'parentOrganization.id': { $exists: true, $eq: sellerId },
266
+ 'containedInPlace.branchCode': { $exists: true, $eq: movieTheaterCode }, // 施設コード
267
+ branchCode: { $eq: roomCode } // ルームコード
268
+ }
269
+ };
270
+ const aggregate = this.placeModel.aggregate([
271
+ // uniwind前はドキュメントの_id指定
272
+ matchStageBeforeUnwind,
273
+ { $unwind: '$containsPlace' },
274
+ // ...matchStages,
275
+ {
276
+ $project: {
277
+ _id: 0,
278
+ // typeOf: '$containsPlace.typeOf',
279
+ branchCode: '$containsPlace.branchCode',
280
+ name: '$containsPlace.name',
281
+ additionalProperty: '$containsPlace.additionalProperty'
282
+ }
283
+ }
284
+ ]);
285
+ if (typeof limit === 'number' && limit > 0) {
286
+ const pageMustBePositive = (typeof page === 'number' && page > 0) ? page : 1;
287
+ aggregate.skip(limit * (pageMustBePositive - 1))
288
+ .limit(limit);
289
+ }
290
+ else {
291
+ throw new factory.errors.Argument('limit', 'must be number > 0');
292
+ }
293
+ return aggregate
294
+ .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
295
+ .exec();
296
+ });
297
+ }
251
298
  deleteScreeningRoomSection(screeningRoomSection) {
252
299
  return __awaiter(this, void 0, void 0, function* () {
253
300
  var _a;
package/package.json CHANGED
@@ -115,5 +115,5 @@
115
115
  "postversion": "git push origin --tags",
116
116
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
117
  },
118
- "version": "23.1.0-alpha.30"
118
+ "version": "23.1.0-alpha.31"
119
119
  }