|
1 | 1 | const getEventsFactory = require('./helpers/eventsFactory').default; |
2 | 2 | const { |
3 | 3 | parseBulkEventIds, |
4 | | - withMergedInvalidEventIds, |
5 | 4 | enqueueAssigneeNotification, |
6 | | - enqueueBulkAssigneeNotifications, |
7 | 5 | } = require('./helpers/bulkEventUtils'); |
8 | 6 | const { aiService } = require('../services/ai'); |
9 | 7 | const { UserInputError } = require('apollo-server-express'); |
@@ -163,8 +161,12 @@ module.exports = { |
163 | 161 |
|
164 | 162 | const factory = getEventsFactory(context, projectId); |
165 | 163 | const result = await factory.bulkVisitEvents(validEventIds, user.id); |
| 164 | + const failedEventIds = Array.from(new Set([...(result.failedEventIds || []), ...invalidEventIds])); |
166 | 165 |
|
167 | | - return withMergedInvalidEventIds(result, invalidEventIds); |
| 166 | + return { |
| 167 | + ...result, |
| 168 | + failedEventIds, |
| 169 | + }; |
168 | 170 | }, |
169 | 171 |
|
170 | 172 | /** |
@@ -207,8 +209,12 @@ module.exports = { |
207 | 209 |
|
208 | 210 | const factory = getEventsFactory(context, projectId); |
209 | 211 | const result = await factory.bulkToggleEventMark(validEventIds, mark); |
| 212 | + const failedEventIds = Array.from(new Set([...(result.failedEventIds || []), ...invalidEventIds])); |
210 | 213 |
|
211 | | - return withMergedInvalidEventIds(result, invalidEventIds); |
| 214 | + return { |
| 215 | + ...result, |
| 216 | + failedEventIds, |
| 217 | + }; |
212 | 218 | }, |
213 | 219 |
|
214 | 220 | /** |
@@ -332,15 +338,20 @@ module.exports = { |
332 | 338 | } |
333 | 339 |
|
334 | 340 | const result = await factory.bulkUpdateAssignee(validEventIds, assignee); |
335 | | - const resultWithInvalid = withMergedInvalidEventIds(result, invalidEventIds); |
| 341 | + const resultWithInvalid = { |
| 342 | + ...result, |
| 343 | + failedEventIds: Array.from(new Set([...(result.failedEventIds || []), ...invalidEventIds])), |
| 344 | + }; |
336 | 345 |
|
337 | 346 | if (assignee && resultWithInvalid.updatedEventIds.length > 0) { |
338 | | - enqueueBulkAssigneeNotifications({ |
339 | | - assigneeData, |
340 | | - assigneeId: assignee, |
341 | | - projectId, |
342 | | - whoAssignedId: user.id, |
343 | | - eventIds: resultWithInvalid.updatedEventIds, |
| 347 | + resultWithInvalid.updatedEventIds.forEach((eventId) => { |
| 348 | + enqueueAssigneeNotification({ |
| 349 | + assigneeData, |
| 350 | + assigneeId: assignee, |
| 351 | + projectId, |
| 352 | + whoAssignedId: user.id, |
| 353 | + eventId, |
| 354 | + }); |
344 | 355 | }); |
345 | 356 | } |
346 | 357 |
|
|
0 commit comments