Added highcharts stats via /stats
This commit is contained in:
31
app/Http/Controllers/StatsController.php
Normal file
31
app/Http/Controllers/StatsController.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use AgliPanci\LaravelCase\Facades\CaseBuilder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use App\Models\SiteVersion;
|
||||
|
||||
class StatsController extends Controller
|
||||
{
|
||||
public function home()
|
||||
{
|
||||
$case = CaseBuilder::whenRaw("version ~ '-dev-'")->thenRaw("CONCAT(SPLIT_PART(version,'-',1),'-',SPLIT_PART(version,'-',2))")
|
||||
->whenRaw("version ~ '-00000000$'")->thenRaw("CONCAT(SPLIT_PART(version,'-',1),'-GH')")
|
||||
->whenRaw("version ~ '^v[0-9]+\.[0-9]+\.[0-9]+'")->thenRaw("SPLIT_PART(version,'-',1)")
|
||||
->elseRaw("'unknown'");
|
||||
|
||||
$stats = SiteVersion::select([
|
||||
DB::raw('DATE(site_versions.created_at) AS created_at'),
|
||||
//'site_versions.version',
|
||||
DB::raw('count(distinct site_id) as total')
|
||||
])
|
||||
->selectRaw($case->toRaw().' AS ver')
|
||||
->groupBy([DB::raw('DATE(site_versions.created_at)'),'ver'])
|
||||
;
|
||||
|
||||
return view('stats')
|
||||
->with('query',$stats->get());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user