@chevre/domain 21.27.0-alpha.16 → 21.27.0-alpha.17
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.
package/example/src/chevre/{aggregateAllEvents.ts → aggregation/createAggregateEventTasks.ts}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
-
|
|
2
|
+
import * as moment from 'moment';
|
|
3
3
|
import * as mongoose from 'mongoose';
|
|
4
4
|
|
|
5
|
-
import { chevre } from '
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const PROJECT = { typeOf: chevre.factory.organizationType.Project, id: String(process.env.PROJECT_ID) };
|
|
8
8
|
|
|
9
9
|
async function main() {
|
|
10
10
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
@@ -12,18 +12,21 @@ async function main() {
|
|
|
12
12
|
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
13
13
|
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const events = <Pick<
|
|
16
|
+
chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEvent>,
|
|
17
|
+
'id' | 'typeOf' | 'startDate' | 'project'
|
|
18
|
+
>[]>await eventRepo.search<chevre.factory.eventType.ScreeningEvent>(
|
|
18
19
|
{
|
|
19
20
|
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
20
|
-
project: { id: { $eq:
|
|
21
|
-
startFrom:
|
|
21
|
+
project: { id: { $eq: PROJECT.id } },
|
|
22
|
+
startFrom: moment()
|
|
23
|
+
.add(-1, 'days')
|
|
24
|
+
.toDate()
|
|
22
25
|
// startFrom: moment().add(-1, 'day').toDate(),
|
|
23
26
|
// startThrough: moment().add(1, 'day').toDate(),
|
|
24
27
|
// startThrough: now
|
|
25
28
|
},
|
|
26
|
-
[],
|
|
29
|
+
['id', 'typeOf', 'startDate', 'project'],
|
|
27
30
|
[]
|
|
28
31
|
);
|
|
29
32
|
|
|
@@ -31,8 +34,8 @@ async function main() {
|
|
|
31
34
|
console.log(events.length);
|
|
32
35
|
// return;
|
|
33
36
|
|
|
34
|
-
const tasks = [];
|
|
35
|
-
for (const
|
|
37
|
+
const tasks: chevre.factory.task.aggregateScreeningEvent.IAttributes[] = [];
|
|
38
|
+
for (const { id, typeOf, startDate, project } of events) {
|
|
36
39
|
const aggregateTask: chevre.factory.task.aggregateScreeningEvent.IAttributes = {
|
|
37
40
|
name: chevre.factory.taskName.AggregateScreeningEvent,
|
|
38
41
|
project: { typeOf: chevre.factory.organizationType.Project, id: project.id },
|
|
@@ -41,10 +44,20 @@ async function main() {
|
|
|
41
44
|
remainingNumberOfTries: 1,
|
|
42
45
|
numberOfTried: 0,
|
|
43
46
|
executionResults: [],
|
|
44
|
-
data: { typeOf
|
|
47
|
+
data: { typeOf, id }
|
|
45
48
|
};
|
|
49
|
+
// const aggregateUseActionsTask: chevre.factory.task.aggregateUseActionsOnEvent.IAttributes = {
|
|
50
|
+
// name: chevre.factory.taskName.AggregateUseActionsOnEvent,
|
|
51
|
+
// project: { typeOf: chevre.factory.organizationType.Project, id: project.id },
|
|
52
|
+
// status: chevre.factory.taskStatus.Ready,
|
|
53
|
+
// runsAt: new Date(),
|
|
54
|
+
// remainingNumberOfTries: 1,
|
|
55
|
+
// numberOfTried: 0,
|
|
56
|
+
// executionResults: [],
|
|
57
|
+
// data: { typeOf, id }
|
|
58
|
+
// };
|
|
46
59
|
tasks.push(aggregateTask);
|
|
47
|
-
console.log('task created',
|
|
60
|
+
console.log('task created', project.id, id, startDate);
|
|
48
61
|
}
|
|
49
62
|
|
|
50
63
|
console.log('creating...', tasks.length, 'tasks');
|
|
@@ -0,0 +1,33 @@
|
|
|
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 EVENT_ID = String(process.env.EVENT_ID);
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const aggregateReservationRepo = await chevre.repository.AggregateReservation.createInstance(mongoose.connection);
|
|
14
|
+
const aggregateReservations = await aggregateReservationRepo.searchWithReservationForId(
|
|
15
|
+
{
|
|
16
|
+
limit: 100,
|
|
17
|
+
page: 1,
|
|
18
|
+
project: { id: { $eq: project.id } },
|
|
19
|
+
reservationFor: {
|
|
20
|
+
id: { $eq: EVENT_ID },
|
|
21
|
+
typeOf: chevre.factory.eventType.ScreeningEvent
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
['aggregateEntranceGate', 'aggregateReservation', 'aggregateOffer']
|
|
25
|
+
);
|
|
26
|
+
console.log('aggregateReservations:', aggregateReservations);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
main()
|
|
30
|
+
.then(() => {
|
|
31
|
+
console.log('success!');
|
|
32
|
+
})
|
|
33
|
+
.catch(console.error);
|
|
@@ -130,13 +130,20 @@ function createInformTasks(params) {
|
|
|
130
130
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
131
131
|
let events4inform;
|
|
132
132
|
if (params.typeOf === factory.eventType.Event) {
|
|
133
|
-
|
|
133
|
+
const eventsFromDB = yield repos.event.search({
|
|
134
134
|
id: { $in: params.ids },
|
|
135
135
|
typeOf: params.typeOf
|
|
136
136
|
}, [], [
|
|
137
137
|
'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
|
|
138
138
|
'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
|
|
139
139
|
]);
|
|
140
|
+
// 最適化(2024-03-26~)
|
|
141
|
+
events4inform = eventsFromDB.map(({ project, organizer, typeOf, name, doorTime, endDate, eventStatus, location, startDate, id, additionalProperty }) => {
|
|
142
|
+
return {
|
|
143
|
+
project, organizer, typeOf, name, doorTime, endDate,
|
|
144
|
+
eventStatus, location, startDate, id, additionalProperty
|
|
145
|
+
};
|
|
146
|
+
});
|
|
140
147
|
}
|
|
141
148
|
else if (params.typeOf === factory.eventType.ScreeningEvent) {
|
|
142
149
|
const screeningEvents4inform = yield repos.event.search({
|
|
@@ -162,7 +169,11 @@ function createInformTasks(params) {
|
|
|
162
169
|
itemOffered: offers.itemOffered,
|
|
163
170
|
seller: {
|
|
164
171
|
id: offers.seller.id,
|
|
165
|
-
typeOf: offers.seller.typeOf
|
|
172
|
+
typeOf: offers.seller.typeOf,
|
|
173
|
+
// makesOfferを追加(2024-03-26~)
|
|
174
|
+
makesOffer: (Array.isArray(offers.seller.makesOffer))
|
|
175
|
+
? offers.seller.makesOffer
|
|
176
|
+
: []
|
|
166
177
|
}
|
|
167
178
|
}
|
|
168
179
|
}
|
package/package.json
CHANGED