@chevre/domain 20.1.0-alpha.26 → 20.1.0-alpha.27
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/migrateCreativeWorkAdditionalProperties.ts +4 -0
- package/example/src/chevre/{migrateSellerMakesOfferTransactionDuration.ts → migrateSSKTSEventCOAEndpoint.ts} +0 -0
- package/lib/chevre/service/event.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +0 -1
- package/package.json +1 -1
- package/example/src/chevre/migrateSection.ts +0 -105
|
@@ -42,6 +42,7 @@ async function main() {
|
|
|
42
42
|
|
|
43
43
|
const additionalPropertyNames: string[] = [];
|
|
44
44
|
const projectIds: string[] = [];
|
|
45
|
+
const unexpextedprojectIds: string[] = [];
|
|
45
46
|
|
|
46
47
|
let i = 0;
|
|
47
48
|
let updateCount = 0;
|
|
@@ -62,10 +63,12 @@ async function main() {
|
|
|
62
63
|
additionalPropertyNamesOnEvent.forEach((name) => {
|
|
63
64
|
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
64
65
|
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
66
|
+
unexpextedprojectIds.push(creativeWork.project.id);
|
|
65
67
|
}
|
|
66
68
|
// tslint:disable-next-line:no-magic-numbers
|
|
67
69
|
if (name.length < 5) {
|
|
68
70
|
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
71
|
+
unexpextedprojectIds.push(creativeWork.project.id);
|
|
69
72
|
}
|
|
70
73
|
});
|
|
71
74
|
|
|
@@ -101,6 +104,7 @@ async function main() {
|
|
|
101
104
|
console.log(updateCount, 'events updated');
|
|
102
105
|
console.log([...new Set(additionalPropertyNames)]);
|
|
103
106
|
console.log([...new Set(projectIds)]);
|
|
107
|
+
console.log([...new Set(unexpextedprojectIds)]);
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
main()
|
|
File without changes
|
|
@@ -475,7 +475,7 @@ function createScreeningEventAdditionalPropertyFromCOA(params) {
|
|
|
475
475
|
return {
|
|
476
476
|
coaInfo,
|
|
477
477
|
additionalProperty: [
|
|
478
|
-
{ name: 'COA_ENDPOINT', value:
|
|
478
|
+
// { name: 'COA_ENDPOINT', value: credentials.coa.endpoint },
|
|
479
479
|
{ name: 'coaInfo', value: JSON.stringify(coaInfo) }
|
|
480
480
|
]
|
|
481
481
|
};
|
|
@@ -579,7 +579,7 @@ function createScreeningEventSeriesAdditionalPropertyFromCOA(params) {
|
|
|
579
579
|
return {
|
|
580
580
|
coaInfo,
|
|
581
581
|
additionalProperty: [
|
|
582
|
-
{ name: 'COA_ENDPOINT', value:
|
|
582
|
+
// { name: 'COA_ENDPOINT', value: credentials.coa.endpoint },
|
|
583
583
|
{ name: 'coaInfo', value: JSON.stringify(coaInfo) }
|
|
584
584
|
]
|
|
585
585
|
};
|
|
@@ -82,7 +82,6 @@ function responseBody2acceptedOffers4result(params) {
|
|
|
82
82
|
coaInfo = event.coaInfo;
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
// const coaEndpointProperty = event.additionalProperty.find((p) => p.name === 'COA_ENDPOINT');
|
|
86
85
|
const coaInfoProperty = (_a = event.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((p) => p.name === 'coaInfo');
|
|
87
86
|
coaInfo = (coaInfoProperty !== undefined) ? JSON.parse(coaInfoProperty.value) : undefined;
|
|
88
87
|
}
|
package/package.json
CHANGED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console no-magic-numbers
|
|
2
|
-
// import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
import * as redis from 'redis';
|
|
5
|
-
|
|
6
|
-
import { chevre } from '../../../lib/index';
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
-
|
|
11
|
-
const client = redis.createClient({
|
|
12
|
-
host: <string>process.env.REDIS_HOST,
|
|
13
|
-
port: Number(process.env.REDIS_PORT),
|
|
14
|
-
password: <string>process.env.REDIS_KEY
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
18
|
-
|
|
19
|
-
const events = await eventRepo.search({
|
|
20
|
-
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
21
|
-
project: { id: { $eq: '' } },
|
|
22
|
-
startFrom: new Date()
|
|
23
|
-
// startThrough: moment().add(4, 'day').toDate()
|
|
24
|
-
});
|
|
25
|
-
console.log(events.length, 'events found');
|
|
26
|
-
|
|
27
|
-
const sectionCode = 'Default';
|
|
28
|
-
await Promise.all(events.map(async (event) => {
|
|
29
|
-
await new Promise<void>((resolve) => {
|
|
30
|
-
const key = `chevre:itemAvailability:screeningEvent:${event.id}`;
|
|
31
|
-
client.hgetall(key, async (__, reply) => {
|
|
32
|
-
if (reply !== null && Object.keys(reply).length > 0) {
|
|
33
|
-
|
|
34
|
-
const fieldAndValues = reply;
|
|
35
|
-
for (const field of Object.keys(fieldAndValues)) {
|
|
36
|
-
// セクションがなければキーを更新
|
|
37
|
-
if (field.slice(0, 7) !== sectionCode) {
|
|
38
|
-
console.log(event.id, field);
|
|
39
|
-
const newField = `${sectionCode}${field}`;
|
|
40
|
-
const newValue = fieldAndValues[field];
|
|
41
|
-
console.log('saving...', newField, newValue);
|
|
42
|
-
|
|
43
|
-
await new Promise<void>((resolveSet) => {
|
|
44
|
-
client.hsetnx(key, newField, newValue, (___, setReply) => {
|
|
45
|
-
console.log('set', setReply, newField, newValue);
|
|
46
|
-
|
|
47
|
-
resolveSet();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// 元のフィールドを削除
|
|
52
|
-
await new Promise<void>((resolveSet) => {
|
|
53
|
-
client.hdel(key, field, (___, setReply) => {
|
|
54
|
-
console.log('deleted', setReply, field);
|
|
55
|
-
|
|
56
|
-
resolveSet();
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
resolve();
|
|
64
|
-
// if (err !== null) {
|
|
65
|
-
// reject(err);
|
|
66
|
-
// } else {
|
|
67
|
-
// if (reply !== null) {
|
|
68
|
-
// client.ttl(targetKey, (ttlErr, ttl) => {
|
|
69
|
-
// console.log('ttl:', ttl);
|
|
70
|
-
// const args = Object.keys(reply)
|
|
71
|
-
// .reduce(
|
|
72
|
-
// (a, b) => {
|
|
73
|
-
// return [...a, b, reply[b]];
|
|
74
|
-
// },
|
|
75
|
-
// []
|
|
76
|
-
// );
|
|
77
|
-
// console.log(args.length, 'args ready');
|
|
78
|
-
|
|
79
|
-
// newClient.multi()
|
|
80
|
-
// .hmset(newKey, ...args)
|
|
81
|
-
// .expire(newKey, ttl)
|
|
82
|
-
// .exec((hmsetErr, reply) => {
|
|
83
|
-
// console.log('hmset result:', hmsetErr, reply);
|
|
84
|
-
// resolve();
|
|
85
|
-
// });
|
|
86
|
-
// });
|
|
87
|
-
// } else {
|
|
88
|
-
// console.error('targetKey not found');
|
|
89
|
-
// }
|
|
90
|
-
// }
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}));
|
|
94
|
-
|
|
95
|
-
// client.keys('chevre:itemAvailability:screeningEvent:*', async (err, reply) => {
|
|
96
|
-
// console.log(err, reply.length, 'keys found');
|
|
97
|
-
// const targetKeys = reply;
|
|
98
|
-
|
|
99
|
-
// });
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
main()
|
|
104
|
-
.then(console.log)
|
|
105
|
-
.catch(console.error);
|