Skip to content

Commit a91b2bd

Browse files
authored
Merge pull request #11114 from nanaya/chunk-options-2
Fetch beatmap qualification problem notification option in batches
2 parents 0641150 + ede3629 commit a91b2bd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: app/Jobs/Notifications/BeatmapsetDiscussionQualifiedProblem.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ public function getListeningUserIds(): array
2929

3030
$ids = [];
3131

32-
$notificationOptions = UserNotificationOption
32+
UserNotificationOption
3333
::where(['name' => Notification::BEATMAPSET_DISCUSSION_QUALIFIED_PROBLEM])
3434
->whereNotNull('details')
35-
->get();
36-
37-
foreach ($notificationOptions as $notificationOption) {
38-
if (count(array_intersect($notificationOption->details['modes'] ?? [], $modes)) > 0) {
39-
$ids[] = $notificationOption->user_id;
40-
}
41-
}
35+
->chunkById(1000, function ($options) use (&$ids, $modes) {
36+
foreach ($options as $option) {
37+
if (count(array_intersect($option->details['modes'] ?? [], $modes)) > 0) {
38+
$ids[] = $option->user_id;
39+
}
40+
}
41+
});
4242

4343
return $ids;
4444
}

0 commit comments

Comments
 (0)