<commit_before><?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

use App\CPUTimes,
    App\Disk,
    App\Memory,
    App\NetIO,
    App\Record,
    App\System;

use Illuminate\Http\Request;

Route::group(['middleware' => ['web']], function () {
    Route::get('/', function () {
        return view('app.overview', [
            'systems' => System::all()
        ]);
    });

    Route::get('/view/system/{system}', function (System $system) {
        return view('app.system', [
            'system'       => $system,
            'latestRecord' => $system->records()->orderBy('id', 'desc')->first(),
            'firstRecord'  => $system->records()->orderBy('id', 'asc')->first(),
        ]);
    });

    Route::delete('/system/{system}', function (System $system) {
        $system->delete();

        return redirect('/');
    });

    Route::get('/system/{system}/{recordCount?}', function (System $system, $recordCount = 60) {
        $validator = Validator::make([
            'recordCount' => $recordCount
        ], [
            'recordCount' => 'required|integer|between:1,3600'
        ]);

        if ($validator->fails()) {
            return view('common.ajax', [
                'return', false,
                'data' => $validator->failed(),
            ]);
        } else {
            $system->load(['records' => function ($query) use ($recordCount) {
                $query->with('cputimes', 'disks', 'memory', 'netio', 'users')<commit_msg>implement deleting old records from the database<commit_after><?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

use App\CPUTimes,
    App\Disk,
    App\Memory,
    App\NetIO,
    App\Record,
    App\System;

use Illuminate\Http\Request;

Route::group(['middleware' => ['web']], function () {
    Route::get('/', function () {
        return view('app.overview', [
            'systems' => System::all()
        ]);
    });

    Route::get('/view/system/{system}', function (System $system) {
        return view('app.system', [
            'system'       => $system,
            'latestRecord' => $system->records()->orderBy('id', 'desc')->first(),
            'firstRecord'  => $system->records()->orderBy('id', 'asc')->first(),
        ]);
    });

    Route::delete('/system/{system}', function (System $system) {
        $system->delete();

        return redirect('/');
    });

    Route::get('/system/{system}/{recordCount?}', function (System $system, $recordCount = 60) {
        $date = new DateTime();
        $date->modify('-1 day');
        $formatted_date = $date->format('Y-m-d H:i:s');

        $system->records()->where('created_at','<=',$formatted_date)->delete();

        $validator = Validator::make([
            'recordCount' => $recordCount
        ], [
            'recordCount' => 'required|integer|between:1,3600'
        ]);

        if ($validator->fails()) {
            return view('common.ajax', [
                'return', false,
                'data' => $validator->failed(),
            ]);
        } else {
            $system->load(['records' => function ($query) use ($recordCount) {
                $query->with('cputimes', 'disks', 'memory', 'netio', 'users')
{'fraction_non_alphanumeric': 0.252212389380531, 'fraction_numerical': 0.0039042165538781884, 'mean_word_length': 1.8721973094170403, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 48, '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': '4076170', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1024, 'n_words': 222}