> */ protected const REVIEWABLE = [Page::class, Project::class, Service::class]; public function key(): string { return 'stale-reviews'; } /** * Whoever can publish something is who a stale review is waiting for, so * seeing the count is the same question as being able to end it. Pages * stand in for the three: a role that can publish none of them has no * business being told what is queued. */ public function permission(): ?string { return 'pages.publish'; } public function run(): Finding { $cutoff = now()->subDays(self::DAYS); $samples = []; $count = 0; foreach (self::REVIEWABLE as $model) { $stale = $model::query() ->awaitingReview() ->where('review_requested_at', '<', $cutoff) ->orderBy('review_requested_at') ->get(); $count += $stale->count(); foreach ($stale as $record) { $samples[] = ContentTypes::title($record) .' ('.$record->review_requested_at->diffForHumans().')'; } } return Finding::problem( $this->key(), $count, Severity::Warning, samples: $samples, ); } }