@chevre/domain 22.12.0-alpha.0 → 22.12.0-alpha.2
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,76 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
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 eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const cursor = eventRepo.getCursor(
|
|
13
|
+
{
|
|
14
|
+
// _id: { $eq: 'bm2bftkoj' },
|
|
15
|
+
'location.maximumAttendeeCapacity': { $exists: true }
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
_id: 1,
|
|
19
|
+
startDate: 1,
|
|
20
|
+
project: 1,
|
|
21
|
+
location: 1,
|
|
22
|
+
maximumPhysicalAttendeeCapacity: 1,
|
|
23
|
+
typeOf: 1
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
console.log('events found');
|
|
27
|
+
|
|
28
|
+
let i = 0;
|
|
29
|
+
let updateCount = 0;
|
|
30
|
+
await cursor.eachAsync(async (doc) => {
|
|
31
|
+
i += 1;
|
|
32
|
+
const event: Pick<
|
|
33
|
+
chevre.factory.event.screeningEvent.IEvent,
|
|
34
|
+
'id' | 'location' | 'startDate' | 'project' | 'maximumPhysicalAttendeeCapacity' | 'typeOf'
|
|
35
|
+
> = doc.toObject();
|
|
36
|
+
|
|
37
|
+
console.log(
|
|
38
|
+
'alreadyMigrated?', event.project.id, event.id, event.startDate, i);
|
|
39
|
+
const originCapacity = event.location.maximumAttendeeCapacity;
|
|
40
|
+
const alreadyMigrated = typeof originCapacity !== 'number'
|
|
41
|
+
|| (typeof originCapacity === 'number' && originCapacity === event.maximumPhysicalAttendeeCapacity);
|
|
42
|
+
|
|
43
|
+
if (alreadyMigrated) {
|
|
44
|
+
console.log(
|
|
45
|
+
'already migrated.', event.project.id, event.id, event.startDate, i);
|
|
46
|
+
} else {
|
|
47
|
+
if (typeof originCapacity === 'number') {
|
|
48
|
+
console.log(
|
|
49
|
+
'updating project... maximumPhysicalAttendeeCapacity:',
|
|
50
|
+
originCapacity,
|
|
51
|
+
event.project.id, event.id, event.startDate, i);
|
|
52
|
+
await eventRepo.updatePartiallyById({
|
|
53
|
+
project: { id: event.project.id },
|
|
54
|
+
id: event.id,
|
|
55
|
+
attributes: {
|
|
56
|
+
typeOf: event.typeOf,
|
|
57
|
+
...{
|
|
58
|
+
maximumPhysicalAttendeeCapacity: originCapacity
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
updateCount += 1;
|
|
63
|
+
console.log(
|
|
64
|
+
'updated.',
|
|
65
|
+
event.project.id, event.id, event.startDate, i);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
console.log(i, 'events checked');
|
|
71
|
+
console.log(updateCount, 'events updated');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
main()
|
|
75
|
+
.then()
|
|
76
|
+
.catch(console.error);
|
|
@@ -11,7 +11,7 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
|
-
await chevre.repository.
|
|
14
|
+
await chevre.repository.Product.createInstance(mongoose.connection);
|
|
15
15
|
console.log('success!');
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -741,8 +741,10 @@ function findAcceptAction(params) {
|
|
|
741
741
|
if (((_b = acceptAction.purpose) === null || _b === void 0 ? void 0 : _b.id) !== params.purpose.id) {
|
|
742
742
|
throw new factory.errors.NotFound('Action');
|
|
743
743
|
}
|
|
744
|
-
const acceptActionWithResult = yield repos.action.findById({ id: acceptAction.id, typeOf: factory.actionType.AcceptAction }, ['result'], []);
|
|
745
|
-
action = Object.assign(Object.assign({ id: acceptAction.id, actionStatus: acceptAction.actionStatus
|
|
744
|
+
const acceptActionWithResult = yield repos.action.findById({ id: acceptAction.id, typeOf: factory.actionType.AcceptAction }, ['result', 'object'], []);
|
|
745
|
+
action = Object.assign(Object.assign({ id: acceptAction.id, actionStatus: acceptAction.actionStatus,
|
|
746
|
+
// add object.transactionNumber(2025-08-26~)
|
|
747
|
+
object: { transactionNumber: acceptActionWithResult.object.transactionNumber } }, (acceptAction.error !== undefined)
|
|
746
748
|
? {
|
|
747
749
|
error: (Array.isArray(acceptAction.error))
|
|
748
750
|
? acceptAction.error[0]
|
package/package.json
CHANGED