@chevre/domain 20.1.0-alpha.22 → 20.1.0-alpha.23

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,89 @@
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 EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
9
+
10
+ // tslint:disable-next-line:max-func-body-length
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
13
+
14
+ const creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
15
+ // const additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
16
+
17
+ const cursor = creativeWorkRepo.getCursor(
18
+ {
19
+ // 'project.id': { $eq: project.id },
20
+ 'project.id': { $ne: EXCLUDED_PROJECT_ID }
21
+ // _id: { $eq: 'al6aff83w' }
22
+ },
23
+ {
24
+ // _id: 1,
25
+ }
26
+ );
27
+ console.log('creativeWorks found');
28
+
29
+ const additionalPropertyNames: string[] = [];
30
+ const projectIds: string[] = [];
31
+
32
+ let i = 0;
33
+ let updateCount = 0;
34
+ await cursor.eachAsync(async (doc) => {
35
+ i += 1;
36
+ const creativeWork: chevre.factory.creativeWork.movie.ICreativeWork = doc.toObject();
37
+
38
+ const additionalPropertyNamesOnEvent = creativeWork.additionalProperty?.map((p) => p.name);
39
+ if (Array.isArray(additionalPropertyNamesOnEvent) && additionalPropertyNamesOnEvent.length > 0) {
40
+ console.log(additionalPropertyNamesOnEvent.length, 'additionalPropertyNamesOnEvent found', creativeWork.project.id);
41
+ additionalPropertyNames.push(...additionalPropertyNamesOnEvent);
42
+ projectIds.push(creativeWork.project.id);
43
+ additionalPropertyNamesOnEvent.forEach((name) => {
44
+ if (!name.match(/^[a-zA-Z]*$/)) {
45
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
46
+ }
47
+ // tslint:disable-next-line:no-magic-numbers
48
+ if (name.length < 5) {
49
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
50
+ }
51
+ });
52
+
53
+ // for (const additionalPropertyNameOnEvent of additionalPropertyNamesOnEvent) {
54
+ // const existings = await additionalPropertyRepo.search({
55
+ // project: { id: { $eq: event.project.id } },
56
+ // limit: 1,
57
+ // page: 1,
58
+ // name: { $regex: `^${additionalPropertyNameOnEvent}$` }
59
+ // });
60
+ // if (existings.length > 0) {
61
+ // console.log('already existed', additionalPropertyNameOnEvent, event.id, event.project.id);
62
+ // } else {
63
+ // updateCount += 1;
64
+ // await additionalPropertyRepo.save({
65
+ // attributes: {
66
+ // project: event.project,
67
+ // typeOf: 'CategoryCode',
68
+ // codeValue: additionalPropertyNameOnEvent,
69
+ // inCodeSet: {
70
+ // typeOf: 'CategoryCodeSet',
71
+ // identifier: <any>event.typeOf
72
+ // },
73
+ // name: { ja: additionalPropertyNameOnEvent }
74
+ // }
75
+ // });
76
+ // console.log('created', additionalPropertyNameOnEvent, event.id, event.project.id);
77
+ // }
78
+ // }
79
+ }
80
+ });
81
+ console.log(i, 'events checked');
82
+ console.log(updateCount, 'events updated');
83
+ console.log([...new Set(additionalPropertyNames)]);
84
+ console.log([...new Set(projectIds)]);
85
+ }
86
+
87
+ main()
88
+ .then()
89
+ .catch(console.error);
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
17
- "@surfrock/sdk": "1.1.0",
17
+ "@surfrock/sdk": "1.2.0-alpha.0",
18
18
  "@waiter/domain": "5.1.0",
19
19
  "JSONStream": "^1.3.5",
20
20
  "aws-sdk": "^2.984.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.1.0-alpha.22"
123
+ "version": "20.1.0-alpha.23"
124
124
  }