@chevre/domain 22.0.0-alpha.21 → 22.0.0-alpha.22
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.
|
@@ -1,77 +1,82 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
|
-
import * as redis from 'redis';
|
|
3
|
+
// import * as redis from 'redis';
|
|
4
4
|
|
|
5
5
|
import { chevre } from '../../../../lib/index';
|
|
6
6
|
|
|
7
7
|
const project = { id: <string>process.env.PROJECT_ID };
|
|
8
|
-
const EVENT_ID = String(process.env.EVENT_ID);
|
|
8
|
+
// const EVENT_ID = String(process.env.EVENT_ID);
|
|
9
9
|
|
|
10
10
|
// tslint:disable-next-line:max-func-body-length
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
await client.connect();
|
|
13
|
+
// const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
14
|
+
// socket: {
|
|
15
|
+
// port: Number(<string>process.env.REDIS_PORT),
|
|
16
|
+
// host: <string>process.env.REDIS_HOST
|
|
17
|
+
// },
|
|
18
|
+
// password: <string>process.env.REDIS_KEY
|
|
19
|
+
// });
|
|
20
|
+
// await client.connect();
|
|
21
21
|
|
|
22
22
|
const aggregateReservationRepo = await chevre.repository.AggregateReservation.createInstance(mongoose.connection);
|
|
23
|
-
|
|
23
|
+
const aggregateReservations = await aggregateReservationRepo.searchWithReservationForId(
|
|
24
24
|
{
|
|
25
|
-
limit:
|
|
25
|
+
limit: 10,
|
|
26
26
|
page: 1,
|
|
27
27
|
project: { id: { $eq: project.id } },
|
|
28
28
|
reservationFor: {
|
|
29
|
-
id: {
|
|
29
|
+
id: {
|
|
30
|
+
$in: [
|
|
31
|
+
'blvcj2vfl', 'blvcj2w48',
|
|
32
|
+
'blvcj2wqj', 'blvcj2y1n',
|
|
33
|
+
'blvcj2ylh', 'blvcj2z7k',
|
|
34
|
+
'blvcj2zqz', 'blvcj30d3',
|
|
35
|
+
'blvcj30wo', 'blvcj32as'
|
|
36
|
+
]
|
|
37
|
+
},
|
|
30
38
|
typeOf: chevre.factory.eventType.ScreeningEvent
|
|
31
|
-
}
|
|
39
|
+
},
|
|
40
|
+
sort: { 'reservationFor.startDate': 1 }
|
|
32
41
|
},
|
|
33
42
|
['aggregateEntranceGate', 'aggregateOffer']
|
|
34
43
|
);
|
|
35
44
|
console.log('aggregateReservations:', aggregateReservations);
|
|
45
|
+
console.log('aggregateReservations:', aggregateReservations.map(({ id }) => id));
|
|
36
46
|
|
|
37
|
-
await (await chevre.service.aggregation.createService()).event.aggregateOffers({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
console.log('aggregateReserveAction processed.');
|
|
47
|
+
// await (await chevre.service.aggregation.createService()).event.aggregateOffers({
|
|
48
|
+
// id: EVENT_ID,
|
|
49
|
+
// typeOf: chevre.factory.eventType.ScreeningEvent
|
|
50
|
+
// })({
|
|
51
|
+
// aggregateReservation: aggregateReservationRepo,
|
|
52
|
+
// event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
53
|
+
// stockHolder: await chevre.repository.StockHolder.createInstance(client, mongoose.connection),
|
|
54
|
+
// offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
55
|
+
// offerCatalog: await chevre.repository.OfferCatalog.createInstance(mongoose.connection),
|
|
56
|
+
// offerRateLimit: await chevre.repository.rateLimit.Offer.createInstance(client),
|
|
57
|
+
// screeningRoom: await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection),
|
|
58
|
+
// product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
59
|
+
// reservation: await chevre.repository.Reservation.createInstance(mongoose.connection)
|
|
60
|
+
// });
|
|
61
|
+
// console.log('aggregateReserveAction processed.');
|
|
52
62
|
|
|
53
|
-
aggregateReservations = await aggregateReservationRepo.searchWithReservationForId(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
[]
|
|
73
|
-
);
|
|
74
|
-
console.log('aggregateReservations:', aggregateReservations);
|
|
63
|
+
// aggregateReservations = await aggregateReservationRepo.searchWithReservationForId(
|
|
64
|
+
// {
|
|
65
|
+
// limit: 1,
|
|
66
|
+
// page: 1,
|
|
67
|
+
// sort: { 'reservationFor.startDate': 1 },
|
|
68
|
+
// project: { id: { $eq: project.id } },
|
|
69
|
+
// reservationFor: {
|
|
70
|
+
// id: {
|
|
71
|
+
// $eq: EVENT_ID,
|
|
72
|
+
// $in: [EVENT_ID]
|
|
73
|
+
// },
|
|
74
|
+
// typeOf: chevre.factory.eventType.ScreeningEvent
|
|
75
|
+
// }
|
|
76
|
+
// },
|
|
77
|
+
// []
|
|
78
|
+
// );
|
|
79
|
+
// console.log('aggregateReservations:', aggregateReservations);
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
main()
|
|
@@ -68,17 +68,18 @@ class AggregateReservationRepo {
|
|
|
68
68
|
var _a;
|
|
69
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
70
|
const matchStages = AggregateReservationRepo.CREATE_MONGO_CONDITIONS(params);
|
|
71
|
-
let
|
|
71
|
+
let projectStage = {
|
|
72
72
|
_id: 0,
|
|
73
73
|
id: '$reservationFor.id'
|
|
74
74
|
};
|
|
75
75
|
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
76
76
|
inclusion.forEach((field) => {
|
|
77
|
-
|
|
77
|
+
projectStage[field] = { $ifNull: [`$${field}`, '$false'] };
|
|
78
|
+
// projectStage[field] = 1;
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
else {
|
|
81
|
-
|
|
82
|
+
projectStage = {
|
|
82
83
|
_id: 0,
|
|
83
84
|
id: '$reservationFor.id',
|
|
84
85
|
aggregateEntranceGate: 1,
|
|
@@ -91,7 +92,16 @@ class AggregateReservationRepo {
|
|
|
91
92
|
...(typeof sortByStartDate === 'number')
|
|
92
93
|
? [{ $sort: { 'reservationFor.startDate': sortByStartDate } }]
|
|
93
94
|
: [],
|
|
94
|
-
|
|
95
|
+
// 現時点でreservationFor.idへのunique indexがないので、重複ドキュメント対応として、$group
|
|
96
|
+
{
|
|
97
|
+
$group: {
|
|
98
|
+
_id: '$reservationFor.id',
|
|
99
|
+
reservationFor: { $first: '$reservationFor' },
|
|
100
|
+
aggregateEntranceGate: { $first: '$aggregateEntranceGate' },
|
|
101
|
+
aggregateOffer: { $first: '$aggregateOffer' }
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{ $project: projectStage }
|
|
95
105
|
]);
|
|
96
106
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
97
107
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
package/package.json
CHANGED