Completed
Push — settings ( bea8d4...96499a )
by Tony
05:40
created

StatsController::index()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
/**
3
 * app/Http/Controllers/Alerting/StatsController.php
4
 *
5
 * HTTP Controller for alert statistics
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 * @package    LibreNMS
21
 * @link       http://librenms.org
22
 * @copyright  2016 Neil Lathwood
23
 * @author     Neil Lathwood <[email protected]>
24
 */
25
26
namespace App\Http\Controllers\Alerting;
27
28
use App\Http\Controllers\Controller;
29
use App\Models\Alerting\Log;
30
use Illuminate\Http\Request;
31
32
class StatsController extends Controller
33
{
34
    /**
35
     * Display a listing of the resource.
36
     *
37
     * @return \Illuminate\Http\Response|null
38
     */
39
    public function index(Request $request)
1 ignored issue
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41
        $data = Log::join('alert_rules', 'alert_rules.id', '=', 'alert_log.rule_id')->where('state', '!=', '0')->groupBy('time_logged')->groupBy('alert_rules.severity')->select('time_logged', 'alert_rules.severity', \DB::raw('COUNT(alert_log.id) as total'))->get();
42
        $output = array();
43
        foreach ($data as $log) {
44
            $output[$log->severity]['label'] = $log->severity;
45
            $output[$log->severity]['data'][] = [$log->time_logged, $log->total];
46
        }
47
        return view('alerting.stats.list', ['output' => $output]);
48
    }
49
50
    /**
51
     * Show the form for creating a new resource.
52
     *
53
     * @return \Illuminate\Http\Response|null
54
     */
55
    public function create()
56
    {
57
        //
58
    }
59
60
    /**
61
     * Store a newly created resource in storage.
62
     *
63
     * @param  \Illuminate\Http\Request  $request
64
     * @return \Illuminate\Http\Response|null
65
     */
66
    public function store(Request $request)
1 ignored issue
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
67
    {
68
        //
69
    }
70
71
    /**
72
     * Display the specified resource.
73
     *
74
     * @param  int  $id
75
     * @return \Illuminate\Http\Response|null
76
     */
77
    public function show($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
78
    {
79
        //
80
    }
81
82
    /**
83
     * Show the form for editing the specified resource.
84
     *
85
     * @param  int  $id
86
     * @return \Illuminate\Http\Response|null
87
     */
88
    public function edit($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
89
    {
90
        //
91
    }
92
93
    /**
94
     * Update the specified resource in storage.
95
     *
96
     * @param  \Illuminate\Http\Request  $request
97
     * @param  int  $id
98
     * @return \Illuminate\Http\Response|null
99
     */
100
    public function update(Request $request, $id)
1 ignored issue
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
101
    {
102
        //
103
    }
104
105
    /**
106
     * Remove the specified resource from storage.
107
     *
108
     * @param  int  $id
109
     * @return \Illuminate\Http\Response|null
110
     */
111
    public function destroy($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
112
    {
113
        //
114
    }
115
}
116