@chevre/domain 21.5.0-alpha.5 → 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()
|
package/package.json
CHANGED