@chevre/domain 22.9.0-alpha.106 → 22.9.0-alpha.107
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.
|
@@ -4,7 +4,7 @@ import * as mongoose from 'mongoose';
|
|
|
4
4
|
import { chevre } from '../../../../lib/index';
|
|
5
5
|
|
|
6
6
|
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
7
|
-
const SCREEN_CODE = '
|
|
7
|
+
const SCREEN_CODE = '100';
|
|
8
8
|
const MOVIE_THEATER_CODE = '118';
|
|
9
9
|
|
|
10
10
|
const formatter = new Intl.NumberFormat('ja-JP');
|
|
@@ -18,54 +18,38 @@ async function main() {
|
|
|
18
18
|
|
|
19
19
|
const seatRepo = await chevre.repository.place.Seat.createInstance(mongoose.connection);
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
setInterval(
|
|
22
|
+
async () => {
|
|
23
|
+
startTime = process.hrtime();
|
|
24
|
+
const seats = <Pick<chevre.factory.place.seat.IPlace, 'branchCode'>[]>await seatRepo.searchSeatsWithSort({
|
|
25
|
+
limit: 100,
|
|
26
|
+
page: 100,
|
|
27
|
+
$projection: {
|
|
28
|
+
'containedInPlace.containedInPlace': 0,
|
|
29
|
+
'containedInPlace.typeOf': 0,
|
|
30
|
+
'containedInPlace.name': 0,
|
|
31
|
+
typeOf: 0,
|
|
32
|
+
additionalProperty: 0
|
|
33
|
+
},
|
|
34
|
+
project: { id: { $eq: PROJECT_ID } },
|
|
35
|
+
// branchCode: { $eq: 'Z-384' },
|
|
36
|
+
containedInPlace: {
|
|
37
|
+
// branchCode: { $eq: 'Default' },
|
|
38
|
+
containedInPlace: {
|
|
39
|
+
branchCode: { $eq: SCREEN_CODE },
|
|
40
|
+
containedInPlace: { branchCode: { $eq: MOVIE_THEATER_CODE } }
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
diff = process.hrtime(startTime);
|
|
45
|
+
// tslint:disable-next-line:no-null-keyword
|
|
46
|
+
console.dir(seats, { depth: null });
|
|
47
|
+
console.log(seats.length, 'seats found');
|
|
48
|
+
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
31
49
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
branchCode: { $eq: SCREEN_CODE },
|
|
36
|
-
containedInPlace: { branchCode: { $eq: MOVIE_THEATER_CODE } }
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
diff = process.hrtime(startTime);
|
|
41
|
-
console.log(seats);
|
|
42
|
-
console.log(seats.length, 'seats found');
|
|
43
|
-
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
44
|
-
|
|
45
|
-
// startTime = process.hrtime();
|
|
46
|
-
// seats = <Pick<chevre.factory.place.seat.IPlace, 'branchCode'>[]>await seatRepo.searchSeats(
|
|
47
|
-
// {
|
|
48
|
-
// limit: 100,
|
|
49
|
-
// page: 1,
|
|
50
|
-
// $projection: {
|
|
51
|
-
// 'containedInPlace.containedInPlace': 0,
|
|
52
|
-
// 'containedInPlace.typeOf': 0,
|
|
53
|
-
// 'containedInPlace.name': 0,
|
|
54
|
-
// typeOf: 0,
|
|
55
|
-
// additionalProperty: 0
|
|
56
|
-
// },
|
|
57
|
-
// project: { id: { $eq: PROJECT_ID } },
|
|
58
|
-
// containedInPlace: {
|
|
59
|
-
// containedInPlace: {
|
|
60
|
-
// branchCode: { $eq: SCREEN_CODE },
|
|
61
|
-
// containedInPlace: { branchCode: { $eq: MOVIE_THEATER_CODE } }
|
|
62
|
-
// }
|
|
63
|
-
// }
|
|
64
|
-
// }
|
|
65
|
-
// );
|
|
66
|
-
// diff = process.hrtime(startTime);
|
|
67
|
-
// console.log(seats.length, 'seats found');
|
|
68
|
-
// console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
50
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
51
|
+
1000
|
|
52
|
+
);
|
|
69
53
|
}
|
|
70
54
|
|
|
71
55
|
main()
|
|
@@ -99,15 +99,6 @@ const indexes = [
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
],
|
|
102
|
-
// [
|
|
103
|
-
// { kanaName: 1, branchCode: 1 },
|
|
104
|
-
// {
|
|
105
|
-
// name: 'searchByKanaName-v2',
|
|
106
|
-
// partialFilterExpression: {
|
|
107
|
-
// kanaName: { $exists: true }
|
|
108
|
-
// }
|
|
109
|
-
// }
|
|
110
|
-
// ],
|
|
111
102
|
[
|
|
112
103
|
{ 'parentOrganization.id': 1, branchCode: 1 },
|
|
113
104
|
{
|
|
@@ -135,15 +126,6 @@ const indexes = [
|
|
|
135
126
|
}
|
|
136
127
|
}
|
|
137
128
|
],
|
|
138
|
-
// [
|
|
139
|
-
// { 'containsPlace.containsPlace.containsPlace.branchCode': 1, branchCode: 1 },
|
|
140
|
-
// {
|
|
141
|
-
// name: 'searchByContainsPlaceContainsPlaceContainsPlaceBranchCode',
|
|
142
|
-
// partialFilterExpression: {
|
|
143
|
-
// 'containsPlace.containsPlace.containsPlace.branchCode': { $exists: true }
|
|
144
|
-
// }
|
|
145
|
-
// }
|
|
146
|
-
// ],
|
|
147
129
|
[
|
|
148
130
|
{ additionalProperty: 1, branchCode: 1 },
|
|
149
131
|
{
|
|
@@ -171,15 +153,6 @@ const indexes = [
|
|
|
171
153
|
}
|
|
172
154
|
}
|
|
173
155
|
],
|
|
174
|
-
// [
|
|
175
|
-
// { 'containsPlace.containsPlace.containsPlace.additionalProperty': 1, branchCode: 1 },
|
|
176
|
-
// {
|
|
177
|
-
// name: 'searchByContainsPlaceContainsPlaceContainsPlaceAdditionalProperty',
|
|
178
|
-
// partialFilterExpression: {
|
|
179
|
-
// 'containsPlace.containsPlace.containsPlace.additionalProperty': { $exists: true }
|
|
180
|
-
// }
|
|
181
|
-
// }
|
|
182
|
-
// ],
|
|
183
156
|
[
|
|
184
157
|
{ 'containedInPlace.id': 1, branchCode: 1 },
|
|
185
158
|
{
|
|
@@ -198,6 +171,36 @@ const indexes = [
|
|
|
198
171
|
}
|
|
199
172
|
}
|
|
200
173
|
]
|
|
174
|
+
// [
|
|
175
|
+
// {
|
|
176
|
+
// 'project.id': 1,
|
|
177
|
+
// 'containsPlace.branchCode': 1,
|
|
178
|
+
// 'containsPlace.containsPlace.branchCode': 1
|
|
179
|
+
// },
|
|
180
|
+
// {
|
|
181
|
+
// name: 'searchSeatsWithSort1'
|
|
182
|
+
// }
|
|
183
|
+
// ],
|
|
184
|
+
// [
|
|
185
|
+
// {
|
|
186
|
+
// 'containedInPlace.branchCode': 1,
|
|
187
|
+
// 'containsPlace.branchCode': 1,
|
|
188
|
+
// 'containsPlace.containsPlace.branchCode': 1
|
|
189
|
+
// },
|
|
190
|
+
// {
|
|
191
|
+
// name: 'searchSeatsWithSort2'
|
|
192
|
+
// }
|
|
193
|
+
// ],
|
|
194
|
+
// [
|
|
195
|
+
// {
|
|
196
|
+
// branchCode: 1,
|
|
197
|
+
// 'containsPlace.branchCode': 1,
|
|
198
|
+
// 'containsPlace.containsPlace.branchCode': 1
|
|
199
|
+
// },
|
|
200
|
+
// {
|
|
201
|
+
// name: 'searchSeatsWithSort3'
|
|
202
|
+
// }
|
|
203
|
+
// ],
|
|
201
204
|
];
|
|
202
205
|
exports.indexes = indexes;
|
|
203
206
|
/**
|
|
@@ -24,7 +24,7 @@ export declare class SeatRepo {
|
|
|
24
24
|
static CREATE_SEARCH_SEATS_PROJECTION(params: factory.place.seat.IProjection): {
|
|
25
25
|
[field: string]: AnyExpression;
|
|
26
26
|
};
|
|
27
|
-
static
|
|
27
|
+
static CREATE_MATCH_STAGES(params: factory.place.seat.ISearchConditions): IMatchStage[];
|
|
28
28
|
createSeat(seat: factory.place.seat.IPlace & {
|
|
29
29
|
parentOrganization?: {
|
|
30
30
|
id?: string;
|
|
@@ -45,7 +45,10 @@ export declare class SeatRepo {
|
|
|
45
45
|
};
|
|
46
46
|
}, $unset: any): Promise<IUpdateSeatResult>;
|
|
47
47
|
searchSeats(params: factory.place.seat.ISearchConditions): Promise<factory.place.seat.IPlace[]>;
|
|
48
|
-
searchSeatsWithSort(params: factory.place.seat.ISearchConditions
|
|
48
|
+
searchSeatsWithSort(params: factory.place.seat.ISearchConditions & {
|
|
49
|
+
limit: number;
|
|
50
|
+
page: number;
|
|
51
|
+
}): Promise<factory.place.seat.IPlace[]>;
|
|
49
52
|
/**
|
|
50
53
|
* 座席区分集計検索
|
|
51
54
|
*/
|
|
@@ -62,7 +62,7 @@ class SeatRepo {
|
|
|
62
62
|
return projectStage;
|
|
63
63
|
}
|
|
64
64
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
65
|
-
static
|
|
65
|
+
static CREATE_MATCH_STAGES(params) {
|
|
66
66
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
67
67
|
const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
|
|
68
68
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -77,6 +77,38 @@ class SeatRepo {
|
|
|
77
77
|
$match: { 'parentOrganization.id': { $exists: true, $eq: parentOrganizationIdEq } }
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
+
if (params.containedInPlace !== undefined) {
|
|
81
|
+
if (params.containedInPlace.containedInPlace !== undefined) {
|
|
82
|
+
if (params.containedInPlace.containedInPlace.containedInPlace !== undefined) {
|
|
83
|
+
if (params.containedInPlace.containedInPlace.containedInPlace.branchCode !== undefined) {
|
|
84
|
+
// 施設
|
|
85
|
+
if (typeof params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
|
|
86
|
+
matchStages.push({
|
|
87
|
+
$match: {
|
|
88
|
+
'containedInPlace.branchCode': {
|
|
89
|
+
// $exists: true, // 不要(2025-04-28~)
|
|
90
|
+
$eq: params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (params.containedInPlace.containedInPlace.branchCode !== undefined) {
|
|
98
|
+
// ルーム
|
|
99
|
+
if (typeof params.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
|
|
100
|
+
matchStages.push({
|
|
101
|
+
$match: {
|
|
102
|
+
branchCode: {
|
|
103
|
+
$eq: params.containedInPlace.containedInPlace.branchCode.$eq
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// セクション
|
|
80
112
|
const containedInPlaceBranchCodeEq = (_f = (_e = params.containedInPlace) === null || _e === void 0 ? void 0 : _e.branchCode) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
81
113
|
if (typeof containedInPlaceBranchCodeEq === 'string') {
|
|
82
114
|
matchStages.push({
|
|
@@ -99,36 +131,7 @@ class SeatRepo {
|
|
|
99
131
|
}
|
|
100
132
|
});
|
|
101
133
|
}
|
|
102
|
-
|
|
103
|
-
if (params.containedInPlace.containedInPlace !== undefined) {
|
|
104
|
-
if (params.containedInPlace.containedInPlace.branchCode !== undefined) {
|
|
105
|
-
if (typeof params.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
|
|
106
|
-
matchStages.push({
|
|
107
|
-
$match: {
|
|
108
|
-
branchCode: {
|
|
109
|
-
$eq: params.containedInPlace.containedInPlace.branchCode.$eq
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (params.containedInPlace.containedInPlace.containedInPlace !== undefined) {
|
|
116
|
-
if (params.containedInPlace.containedInPlace.containedInPlace.branchCode !== undefined) {
|
|
117
|
-
if (typeof params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq === 'string') {
|
|
118
|
-
matchStages.push({
|
|
119
|
-
$match: {
|
|
120
|
-
'containedInPlace.branchCode': {
|
|
121
|
-
$exists: true,
|
|
122
|
-
$eq: params.containedInPlace.containedInPlace.containedInPlace.branchCode.$eq
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
// 座席コード
|
|
134
|
+
// 座席
|
|
132
135
|
if (params.branchCode !== undefined) {
|
|
133
136
|
if (typeof params.branchCode.$eq === 'string') {
|
|
134
137
|
matchStages.push({
|
|
@@ -330,7 +333,7 @@ class SeatRepo {
|
|
|
330
333
|
}
|
|
331
334
|
searchSeats(params) {
|
|
332
335
|
return __awaiter(this, void 0, void 0, function* () {
|
|
333
|
-
const matchStages = SeatRepo.
|
|
336
|
+
const matchStages = SeatRepo.CREATE_MATCH_STAGES(params);
|
|
334
337
|
const projectStage = SeatRepo.CREATE_SEARCH_SEATS_PROJECTION(Object.assign({}, params.$projection));
|
|
335
338
|
const aggregate = this.placeModel.aggregate([
|
|
336
339
|
{
|
|
@@ -360,9 +363,10 @@ class SeatRepo {
|
|
|
360
363
|
}
|
|
361
364
|
searchSeatsWithSort(params) {
|
|
362
365
|
return __awaiter(this, void 0, void 0, function* () {
|
|
363
|
-
const matchStages = SeatRepo.
|
|
366
|
+
const matchStages = SeatRepo.CREATE_MATCH_STAGES(params);
|
|
364
367
|
const projectStage = SeatRepo.CREATE_SEARCH_SEATS_PROJECTION(Object.assign({}, params.$projection));
|
|
365
|
-
const
|
|
368
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
369
|
+
const pipeline = [
|
|
366
370
|
...matchStages,
|
|
367
371
|
{
|
|
368
372
|
$unwind: {
|
|
@@ -377,9 +381,19 @@ class SeatRepo {
|
|
|
377
381
|
}
|
|
378
382
|
},
|
|
379
383
|
...matchStages,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
384
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
385
|
+
// TODO reimplement using $sort + $skip + $limit(2025-4-27~)
|
|
386
|
+
{ $limit: params.limit * page },
|
|
387
|
+
{ $skip: params.limit * (page - 1) },
|
|
388
|
+
// {
|
|
389
|
+
// $sort: {
|
|
390
|
+
// 'containsPlace.branchCode': factory.sortType.Ascending,
|
|
391
|
+
// 'containsPlace.containsPlace.branchCode': factory.sortType.Ascending
|
|
392
|
+
// }
|
|
393
|
+
// },
|
|
394
|
+
// { $skip: params.limit * (page - 1) },
|
|
395
|
+
// { $limit: params.limit },
|
|
396
|
+
{ $project: projectStage }
|
|
383
397
|
// {
|
|
384
398
|
// $project: {
|
|
385
399
|
// ...projectStage,
|
|
@@ -397,20 +411,13 @@ class SeatRepo {
|
|
|
397
411
|
// // }
|
|
398
412
|
// }
|
|
399
413
|
// }
|
|
400
|
-
]
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
// aggregate
|
|
408
|
-
// .sort({ combinedIndex: factory.sortType.Ascending })
|
|
409
|
-
// .skip(params.limit * (page - 1))
|
|
410
|
-
// .limit(params.limit);
|
|
411
|
-
}
|
|
412
|
-
return aggregate
|
|
413
|
-
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
414
|
+
];
|
|
415
|
+
// console.log(pipeline);
|
|
416
|
+
return this.placeModel.aggregate(pipeline)
|
|
417
|
+
.option({
|
|
418
|
+
maxTimeMS: settings_1.MONGO_MAX_TIME_MS
|
|
419
|
+
// explain: true
|
|
420
|
+
})
|
|
414
421
|
.exec();
|
|
415
422
|
});
|
|
416
423
|
}
|
package/package.json
CHANGED