@chevre/domain 21.5.0 → 21.6.0-alpha.0
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
-
|
|
2
|
+
import * as moment from 'moment';
|
|
3
3
|
import * as mongoose from 'mongoose';
|
|
4
4
|
|
|
5
5
|
import { chevre } from '../../../lib/index';
|
|
@@ -20,17 +20,17 @@ async function main() {
|
|
|
20
20
|
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
21
21
|
typeOf: {
|
|
22
22
|
$in: [
|
|
23
|
-
chevre.factory.eventType.ScreeningEvent,
|
|
23
|
+
// chevre.factory.eventType.ScreeningEvent,
|
|
24
24
|
chevre.factory.eventType.ScreeningEventSeries
|
|
25
25
|
]
|
|
26
26
|
},
|
|
27
|
-
organizer: { $exists:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
organizer: { $exists: true },
|
|
28
|
+
startDate: {
|
|
29
|
+
$gte: moment()
|
|
30
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
31
|
+
.add(-3, 'months')
|
|
32
|
+
.toDate()
|
|
33
|
+
}
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
_id: 1,
|
|
@@ -46,6 +46,7 @@ async function main() {
|
|
|
46
46
|
|
|
47
47
|
let i = 0;
|
|
48
48
|
let updateCount = 0;
|
|
49
|
+
let invalidOrganizerCount = 0;
|
|
49
50
|
await cursor.eachAsync(async (doc) => {
|
|
50
51
|
i += 1;
|
|
51
52
|
const event: Pick<
|
|
@@ -57,43 +58,49 @@ async function main() {
|
|
|
57
58
|
> = doc.toObject();
|
|
58
59
|
|
|
59
60
|
const organizerId = event.organizer?.id;
|
|
61
|
+
|
|
62
|
+
let movieTheaterId: string;
|
|
63
|
+
let movieTheaterBranchCode: string;
|
|
64
|
+
if (event.typeOf === chevre.factory.eventType.ScreeningEventSeries) {
|
|
65
|
+
movieTheaterId = event.location.id;
|
|
66
|
+
movieTheaterBranchCode = event.location.branchCode;
|
|
67
|
+
} else {
|
|
68
|
+
movieTheaterId = event.superEvent.location.id;
|
|
69
|
+
movieTheaterBranchCode = event.superEvent.location.branchCode;
|
|
70
|
+
}
|
|
71
|
+
const movieTheaters = <Pick<
|
|
72
|
+
chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom,
|
|
73
|
+
'parentOrganization' | 'branchCode'
|
|
74
|
+
>[]>
|
|
75
|
+
await placeRepo.searchMovieTheaters(
|
|
76
|
+
{
|
|
77
|
+
limit: 1,
|
|
78
|
+
page: 1,
|
|
79
|
+
project: { id: { $eq: event.project.id } },
|
|
80
|
+
id: { $eq: movieTheaterId }
|
|
81
|
+
},
|
|
82
|
+
['parentOrganization', 'branchCode'],
|
|
83
|
+
[]
|
|
84
|
+
);
|
|
85
|
+
const movieTheater = movieTheaters.shift();
|
|
86
|
+
const sellerId = movieTheater?.parentOrganization?.id;
|
|
87
|
+
console.log(
|
|
88
|
+
'movieTheater found',
|
|
89
|
+
event.project.id, event.id, event.startDate, 'sellerId:', sellerId,
|
|
90
|
+
'movieTheaterId:', movieTheaterId,
|
|
91
|
+
'movieTheaterBranchCode:', movieTheaterBranchCode,
|
|
92
|
+
i
|
|
93
|
+
);
|
|
94
|
+
|
|
60
95
|
const alreadyMigrated = typeof organizerId === 'string';
|
|
61
96
|
|
|
62
97
|
if (alreadyMigrated) {
|
|
63
98
|
console.log('already exist...', event.project.id, event.id, event.startDate, organizerId, i);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
let movieTheaterBranchCode: string;
|
|
67
|
-
if (event.typeOf === chevre.factory.eventType.ScreeningEventSeries) {
|
|
68
|
-
movieTheaterId = event.location.id;
|
|
69
|
-
movieTheaterBranchCode = event.location.branchCode;
|
|
70
|
-
} else {
|
|
71
|
-
movieTheaterId = event.superEvent.location.id;
|
|
72
|
-
movieTheaterBranchCode = event.superEvent.location.branchCode;
|
|
99
|
+
if (organizerId !== sellerId) {
|
|
100
|
+
invalidOrganizerCount += 1;
|
|
73
101
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
'parentOrganization' | 'branchCode'
|
|
77
|
-
>[]>
|
|
78
|
-
await placeRepo.searchMovieTheaters(
|
|
79
|
-
{
|
|
80
|
-
limit: 1,
|
|
81
|
-
page: 1,
|
|
82
|
-
project: { id: { $eq: event.project.id } },
|
|
83
|
-
id: { $eq: movieTheaterId }
|
|
84
|
-
},
|
|
85
|
-
['parentOrganization', 'branchCode'],
|
|
86
|
-
[]
|
|
87
|
-
);
|
|
88
|
-
const movieTheater = movieTheaters.shift();
|
|
89
|
-
const sellerId = movieTheater?.parentOrganization?.id;
|
|
90
|
-
console.log(
|
|
91
|
-
'movieTheater found',
|
|
92
|
-
event.project.id, event.id, event.startDate, 'sellerId:', sellerId,
|
|
93
|
-
'movieTheaterId:', movieTheaterId,
|
|
94
|
-
'movieTheaterBranchCode:', movieTheaterBranchCode,
|
|
95
|
-
i
|
|
96
|
-
);
|
|
102
|
+
} else {
|
|
103
|
+
throw new Error('organizer not found');
|
|
97
104
|
// if (typeof sellerId !== 'string') {
|
|
98
105
|
// throw new Error('movieTheater not found');
|
|
99
106
|
// }
|
|
@@ -118,6 +125,7 @@ async function main() {
|
|
|
118
125
|
|
|
119
126
|
console.log(i, 'events checked');
|
|
120
127
|
console.log(updateCount, 'events updated');
|
|
128
|
+
console.log(invalidOrganizerCount, 'invalid');
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
main()
|
|
@@ -0,0 +1,70 @@
|
|
|
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, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = creativeWorkRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
'offers.availabilityEnds': { $exists: true }
|
|
19
|
+
},
|
|
20
|
+
{}
|
|
21
|
+
);
|
|
22
|
+
console.log('creativeWorks found');
|
|
23
|
+
|
|
24
|
+
let i = 0;
|
|
25
|
+
let updateCount = 0;
|
|
26
|
+
let datePublishedUndefinedCount = 0;
|
|
27
|
+
await cursor.eachAsync(async (doc) => {
|
|
28
|
+
i += 1;
|
|
29
|
+
const movie: chevre.factory.creativeWork.movie.ICreativeWork = doc.toObject();
|
|
30
|
+
|
|
31
|
+
const availabilityEnds = movie.offers.availabilityEnds;
|
|
32
|
+
let availabilityStarts = movie.offers.availabilityStarts;
|
|
33
|
+
const createdAt: Date = (<any>movie).createdAt;
|
|
34
|
+
if (!(createdAt instanceof Date)) {
|
|
35
|
+
throw new Error('createdAt not Date');
|
|
36
|
+
}
|
|
37
|
+
const alreadyMigrated = availabilityStarts instanceof Date;
|
|
38
|
+
|
|
39
|
+
if (alreadyMigrated) {
|
|
40
|
+
console.log('already exist...', movie.project.id, movie.id, movie.identifier, availabilityStarts, availabilityEnds, i);
|
|
41
|
+
} else {
|
|
42
|
+
if (movie.datePublished === undefined) {
|
|
43
|
+
console.error('movie.datePublished undefined', movie.project.id, movie.id, movie.identifier, i);
|
|
44
|
+
// throw new Error('movie.datePublished undefined');
|
|
45
|
+
datePublishedUndefinedCount += 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
availabilityStarts = (movie.datePublished !== undefined)
|
|
49
|
+
? moment(movie.datePublished)
|
|
50
|
+
.toDate()
|
|
51
|
+
: moment(createdAt)
|
|
52
|
+
.toDate();
|
|
53
|
+
console.log('updating movie...', movie.project.id, movie.id, movie.identifier, availabilityStarts, availabilityEnds, i);
|
|
54
|
+
await creativeWorkRepo.saveMovie(<any>{
|
|
55
|
+
id: String(movie.id),
|
|
56
|
+
'offers.availabilityStarts': availabilityStarts
|
|
57
|
+
});
|
|
58
|
+
updateCount += 1;
|
|
59
|
+
console.log('updated.', movie.project.id, movie.id, movie.identifier, availabilityStarts, availabilityEnds, i);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
console.log(i, 'creativeWorks checked');
|
|
64
|
+
console.log(updateCount, 'creativeWorks updated');
|
|
65
|
+
console.log(datePublishedUndefinedCount, 'datePublishedUndefinedCount');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
main()
|
|
69
|
+
.then()
|
|
70
|
+
.catch(console.error);
|
|
@@ -37,7 +37,7 @@ function createEvent(params) {
|
|
|
37
37
|
const firstCreatingEventParams = creatingEventParams[0];
|
|
38
38
|
const movieTheaters = yield repos.place.searchMovieTheaters({
|
|
39
39
|
project: { id: { $eq: actionAttributes.project.id } }
|
|
40
|
-
}, ['_id', 'branchCode', 'kanaName', 'name'], []);
|
|
40
|
+
}, ['_id', 'branchCode', 'kanaName', 'name', 'parentOrganization'], []);
|
|
41
41
|
creatingEventParams = movieTheaters.map((movieTheater) => {
|
|
42
42
|
const location = {
|
|
43
43
|
branchCode: movieTheater.branchCode,
|
|
@@ -46,8 +46,13 @@ function createEvent(params) {
|
|
|
46
46
|
name: movieTheater.name,
|
|
47
47
|
typeOf: factory.placeType.MovieTheater
|
|
48
48
|
};
|
|
49
|
+
const organizer = {
|
|
50
|
+
id: movieTheater.parentOrganization.id
|
|
51
|
+
};
|
|
49
52
|
return {
|
|
50
|
-
attributes: Object.assign(Object.assign({}, firstCreatingEventParams.attributes), { location
|
|
53
|
+
attributes: Object.assign(Object.assign({}, firstCreatingEventParams.attributes), { location,
|
|
54
|
+
// organizerがfirstCreatingEventParamsにそろってしまうbug対応(2023-08-03~)
|
|
55
|
+
organizer })
|
|
51
56
|
};
|
|
52
57
|
});
|
|
53
58
|
}
|
package/package.json
CHANGED