From 06b9bc27579af3fe54de6333aa68a8cc0fbfad49 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Fri, 8 May 2015 11:06:02 +0100 Subject: [PATCH] Prevent bots from indexing date ranges with no incidents. Closes #624. --- app/Http/Controllers/HomeController.php | 3 +++ resources/views/index.blade.php | 2 ++ 2 files changed, 5 insertions(+) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index a07c9a13b..56875c76c 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -108,6 +108,8 @@ class HomeController extends AbstractController $componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->get(); $ungroupedComponents = Component::where('group_id', 0)->orderBy('order')->orderBy('created_at')->get(); + $canPageBackward = Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() != 0; + return View::make('index', [ 'componentGroups' => $componentGroups, 'ungroupedComponents' => $ungroupedComponents, @@ -118,6 +120,7 @@ class HomeController extends AbstractController 'pageTitle' => Setting::get('app_name'), 'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')), 'canPageForward' => (bool) $today->gt($startDate), + 'canPageBackward' => $canPageBackward, 'previousDate' => $startDate->copy()->subDays($daysToShow)->toDateString(), 'nextDate' => $startDate->copy()->addDays($daysToShow)->toDateString(), ]); diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index ec59d1cd6..088044c5b 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -41,11 +41,13 @@