6 - Reset consecutive_poll_failures on successful poll

This commit is contained in:
myrmidex 2026-04-29 21:09:44 +02:00
parent 920985eec8
commit bbd74c1954
2 changed files with 10 additions and 1 deletions

View file

@ -5,7 +5,6 @@
namespace Lvl0\FediDiscover\Actions;
use Carbon\CarbonImmutable;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Lvl0\FediDiscover\Clients\FediverseClientFactory;
use Lvl0\FediDiscover\Events\UrlDiscovered;
@ -44,6 +43,7 @@ public function execute(Instance $instance): void
$instance->last_seen_id = $posts->first()->cursorId;
}
$instance->consecutive_poll_failures = 0;
$instance->last_polled_at = now();
$instance->save();

View file

@ -199,6 +199,15 @@ public function test_it_leaves_last_seen_id_unchanged_when_no_posts_are_returned
$this->assertSame('500', $instance->fresh()->last_seen_id);
}
public function test_consecutive_poll_failures_reset_to_zero_after_successful_poll(): void
{
$instance = $this->makeInstance(['consecutive_poll_failures' => 5]);
$this->pollInstance($instance, []);
$this->assertSame(0, $instance->fresh()->consecutive_poll_failures);
}
public function test_poll_logs_a_structured_success_entry_with_url_count_and_duration(): void
{
Log::spy();