<commit_before><?php

namespace CachetHQ\Cachet\Http\Controllers;

use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Incident;
use Carbon\Carbon;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\View;
use Jenssegers\Date\Date;

class HomeController extends Controller
{
    /**
     * Returns the rendered Blade templates.
     *
     * @return \Illuminate\View\View
     */
    public function showIndex()
    {
        $components = Component::orderBy('order')->orderBy('created_at')->get();

        $allIncidents = [];

        $incidentDays = Setting::get('app_incident_days') ?: 7;

        $today = Carbon::now();
        $startDate = Carbon::now();

        $dateFormat = Setting::get('date_format') ?: 'jS F Y';

        // Check if we have another starting date
        if (Binput::has('start_date')) {
            try {
                // If date provided is valid
                $oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
                // If trying to get a future date fallback to today
                if ($today->gt($oldDate)) {
                    $startDate = $oldDate;
                }
            } catch (Exception $e) {
                // Fallback to today
            }
        }

        foreach (range(0, $incidentDays) as $i) {
            $date = $startDate->copy()->subDays($i);

            $incidents = Incident::whereBetween('created_at', [
                $date->format('Y-m-d').' 00:00:00',
                $date->format('Y-m-d').' 23:59:59',
            ])->orderBy('created_at', 'desc')->get();

            $allIncidents[] = [
                'date'      => (new Date($date->toDateTimeString()))->format($dateFormat),
                'incidents' => $incidents,
            ];
        }

        return View::make('index', [
            'components'     => $components,
            'allIncidents'   => $allIncidents,
            'pageTitle'      => Setting::get('app_name'),
            'aboutApp'       => Markdown::render(Setting::get('app_about')),
            'canPageForward' => (bool) $today->gt($startDate),
            'previousDate'   => $startDate->copy()->subWeek()->subDay()->toDateString(),
            'nextDate'       => $startDate->copy()->addWeek()->addDay()->toDateString(),
        ]);
    }
}<commit_msg>Remove unnecessary form incidents day<commit_after><?php

namespace CachetHQ\Cachet\Http\Controllers;

use CachetHQ\Cachet\Facades\Setting;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Incident;
use Carbon\Carbon;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\View;
use Jenssegers\Date\Date;

class HomeController extends Controller
{
    /**
     * Returns the rendered Blade templates.
     *
     * @return \Illuminate\View\View
     */
    public function showIndex()
    {
        $components = Component::orderBy('order')->orderBy('created_at')->get();

        $allIncidents = [];

        $incidentDays = Setting::get('app_incident_days') ?: 7;

        $today = Carbon::now();
        $startDate = Carbon::now();

        $dateFormat = Setting::get('date_format') ?: 'jS F Y';

        // Check if we have another starting date
        if (Binput::has('start_date')) {
            try {
                // If date provided is valid
                $oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
                // If trying to get a future date fallback to today
                if ($today->gt($oldDate)) {
                    $startDate = $oldDate;
                }
            } catch (Exception $e) {
                // Fallback to today
            }
        }

        foreach (range(0, $incidentDays) as $i) {
            $date = $startDate->copy()->subDays($i);

            $incidents = Incident::whereBetween('created_at', [
                $date->format('Y-m-d').' 00:00:00',
                $date->format('Y-m-d').' 23:59:59',
            ])->orderBy('created_at', 'desc')->get();

            $allIncidents[] = [
                'date'      => (new Date($date->toDateString()))->format($dateFormat),
                'incidents' => $incidents,
            ];
        }

        return View::make('index', [
            'components'     => $components,
            'allIncidents'   => $allIncidents,
            'pageTitle'      => Setting::get('app_name'),
            'aboutApp'       => Markdown::render(Setting::get('app_about')),
            'canPageForward' => (bool) $today->gt($startDate),
            'previousDate'   => $startDate->copy()->subWeek()->subDay()->toDateString(),
            'nextDate'       => $startDate->copy()->addWeek()->addDay()->toDateString(),
        ]);
    }
}
{'fraction_non_alphanumeric': 0.1593851132686084, 'fraction_numerical': 0.0056634304207119745, 'mean_word_length': 2.127767235926629, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7306604', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1433, 'n_words': 260}