31 lines
908 B
PHP
31 lines
908 B
PHP
<?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),'-GIT')")
|
|
->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());
|
|
}
|
|
} |