Skip to content

Commit 4d40138

Browse files
committed
Update NotificationEpochUpdatePipeline, use more efficient query
1 parent 152b6ea commit 4d40138

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/Jobs/InternalPipeline/NotificationEpochUpdatePipeline.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ public function __construct()
6161
*/
6262
public function handle(): void
6363
{
64-
$rec = Notification::where('created_at', '>', now()->subMonths(6))->first();
64+
$pid = Cache::get(NotificationService::EPOCH_CACHE_KEY . '6');
65+
if($pid && $pid > 1) {
66+
$rec = Notification::where('id', '>', $pid)->whereDate('created_at', now()->subMonths(6)->format('Y-m-d'))->first();
67+
} else {
68+
$rec = Notification::whereDate('created_at', now()->subMonths(6)->format('Y-m-d'))->first();
69+
}
6570
$id = 1;
6671
if($rec) {
6772
$id = $rec->id;

0 commit comments

Comments
 (0)