diff --git a/src/Models/Contracts/MonitorContract.php b/src/Models/Contracts/MonitorContract.php index ada798f9..03240b76 100644 --- a/src/Models/Contracts/MonitorContract.php +++ b/src/Models/Contracts/MonitorContract.php @@ -7,4 +7,13 @@ */ interface MonitorContract { + /** + * @return \Illuminate\Database\Eloquent\Builder<\romanzipp\QueueMonitor\Models\Monitor> + */ + public function newQuery(); + + /** + * @return string + */ + public function getTable(); } diff --git a/tests/PurgeCommandTest.php b/tests/PurgeCommandTest.php index 8be34874..084be86c 100644 --- a/tests/PurgeCommandTest.php +++ b/tests/PurgeCommandTest.php @@ -18,14 +18,14 @@ protected function tearDown(): void public function testDate() { - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(15)]); self::assertSame(8, Monitor::query()->count()); @@ -34,16 +34,34 @@ public function testDate() self::assertSame(4, Monitor::query()->count()); } + public function testDateChunked() + { + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(15)]); + + self::assertSame(8, Monitor::query()->count()); + + $this->artisan('queue-monitor:purge --chunk --before=' . Carbon::now()->subDays(30)->format('Y-m-d')); + + self::assertSame(4, Monitor::query()->count()); + } + public function testDays() { - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(15)]); self::assertSame(8, Monitor::query()->count()); @@ -52,16 +70,34 @@ public function testDays() self::assertSame(4, Monitor::query()->count()); } + public function testDaysChunked() + { + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(15)]); + + self::assertSame(8, Monitor::query()->count()); + + $this->artisan('queue-monitor:purge --chunk --beforeDays=30'); + + self::assertSame(4, Monitor::query()->count()); + } + public function testInterval() { - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(15)]); self::assertSame(8, Monitor::query()->count()); @@ -70,16 +106,34 @@ public function testInterval() self::assertSame(4, Monitor::query()->count()); } + public function testIntervalChunked() + { + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(15)]); + + self::assertSame(8, Monitor::query()->count()); + + $this->artisan('queue-monitor:purge --chunk --beforeInterval=P30D'); + + self::assertSame(4, Monitor::query()->count()); + } + public function testDateOnlySuccessfull() { - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(15)]); self::assertSame(8, Monitor::query()->count()); @@ -90,14 +144,14 @@ public function testDateOnlySuccessfull() public function testDaysOnlySuccessfull() { - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(15)]); self::assertSame(8, Monitor::query()->count()); @@ -108,14 +162,14 @@ public function testDaysOnlySuccessfull() public function testIntervalOnlySuccessfull() { - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(15)]); self::assertSame(8, Monitor::query()->count()); @@ -126,14 +180,14 @@ public function testIntervalOnlySuccessfull() public function testQueues() { - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(15), 'queue' => 'foobar']); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(15), 'queue' => 'foobar']); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(15), 'queue' => 'foobar']); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(15), 'queue' => 'foobar']); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(15), 'queue' => 'bar']); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(15), 'queue' => 'bar']); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(15), 'queue' => 'foo']); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(15), 'queue' => 'foo']); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(15), 'queue' => 'foobar']); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(15), 'queue' => 'foobar']); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(15), 'queue' => 'foobar']); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(15), 'queue' => 'foobar']); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(15), 'queue' => 'bar']); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(15), 'queue' => 'bar']); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(15), 'queue' => 'foo']); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(15), 'queue' => 'foo']); self::assertSame(8, Monitor::query()->count()); @@ -144,14 +198,14 @@ public function testQueues() public function testDry() { - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(60)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'started_at' => Carbon::now()->subDays(15)]); - Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'started_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(60)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::SUCCEEDED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::RUNNING, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::FAILED, 'queued_at' => Carbon::now()->subDays(15)]); + Monitor::query()->create(['job_id' => 'foo', 'status' => MonitorStatus::STALE, 'queued_at' => Carbon::now()->subDays(15)]); self::assertSame(8, Monitor::query()->count());