@chevre/domain 23.1.0-alpha.24 → 23.1.0-alpha.25
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,93 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
const DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET = 'MovieTicket';
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = eventSeriesRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
'project.id': { $eq: 'xxx' },
|
|
19
|
+
'offers.unacceptedPaymentMethod': {
|
|
20
|
+
$exists: true,
|
|
21
|
+
$ne: DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
|
|
22
|
+
},
|
|
23
|
+
startDate: {
|
|
24
|
+
$lte: moment()
|
|
25
|
+
.add(-1, 'year')
|
|
26
|
+
.toDate()
|
|
27
|
+
}
|
|
28
|
+
// _id: { $eq: 'bliy11ffa' }
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
// _id: 1,
|
|
32
|
+
// offers: 1,
|
|
33
|
+
// startDate: 1,
|
|
34
|
+
// project: 1,
|
|
35
|
+
// typeOf: 1
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
console.log('docs found');
|
|
39
|
+
|
|
40
|
+
let i = 0;
|
|
41
|
+
let updateCount = 0;
|
|
42
|
+
await cursor.eachAsync(async (doc) => {
|
|
43
|
+
i += 1;
|
|
44
|
+
const eventSeries: Pick<
|
|
45
|
+
chevre.factory.eventSeries.IEvent,
|
|
46
|
+
'id' | 'offers' | 'startDate' | 'project' | 'typeOf'
|
|
47
|
+
> = doc.toObject();
|
|
48
|
+
|
|
49
|
+
console.log(
|
|
50
|
+
'alreadyMigrated?', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
51
|
+
const unacceptedPaymentMethod = eventSeries.offers?.unacceptedPaymentMethod;
|
|
52
|
+
const alreadyMigrated = !Array.isArray(unacceptedPaymentMethod)
|
|
53
|
+
|| (Array.isArray(unacceptedPaymentMethod)
|
|
54
|
+
&& unacceptedPaymentMethod.every(
|
|
55
|
+
(paymentMethodType) => paymentMethodType === DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
|
|
56
|
+
));
|
|
57
|
+
|
|
58
|
+
if (alreadyMigrated) {
|
|
59
|
+
console.log(
|
|
60
|
+
'already migrated.', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
61
|
+
} else {
|
|
62
|
+
if (Array.isArray(unacceptedPaymentMethod)) {
|
|
63
|
+
const newUnacceptedPaymentMethod = unacceptedPaymentMethod.filter(
|
|
64
|
+
(paymentMethod) => paymentMethod === DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
|
|
65
|
+
);
|
|
66
|
+
console.log(
|
|
67
|
+
'updating project...',
|
|
68
|
+
newUnacceptedPaymentMethod,
|
|
69
|
+
eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
70
|
+
await eventSeriesRepo.saveEventSeries({
|
|
71
|
+
id: eventSeries.id,
|
|
72
|
+
attributes: <any>{
|
|
73
|
+
...{
|
|
74
|
+
typeOf: eventSeries.typeOf,
|
|
75
|
+
'offers.unacceptedPaymentMethod': newUnacceptedPaymentMethod
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
updateCount += 1;
|
|
80
|
+
console.log(
|
|
81
|
+
'updated.',
|
|
82
|
+
eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
console.log(i, 'docs checked');
|
|
88
|
+
console.log(updateCount, 'docs updated');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
main()
|
|
92
|
+
.then()
|
|
93
|
+
.catch(console.error);
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "5.4.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "12.11.0
|
|
14
|
+
"@chevre/factory": "5.4.0-alpha.1",
|
|
15
|
+
"@cinerino/sdk": "12.11.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
18
18
|
"@sendgrid/client": "8.1.4",
|
|
@@ -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.
|
|
118
|
+
"version": "23.1.0-alpha.25"
|
|
119
119
|
}
|