-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from P3D-Legacy/stats
Stats
- Loading branch information
Showing
22 changed files
with
327 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
|
||
class StatsController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function index() | ||
{ | ||
return view('stats.index'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Http\Livewire\Admin; | ||
|
||
use App\Stats\ResourceCreationStats; | ||
use Livewire\Component; | ||
|
||
class ResourceCreationStatsGraph extends Component | ||
{ | ||
public $stats; | ||
public $labels; | ||
public $values; | ||
|
||
public function mount() | ||
{ | ||
$this->stats = ResourceCreationStats::query() | ||
->start(now()->subDays(10)) | ||
->end(now()->subSecond()) | ||
->groupByDay() | ||
->get(); | ||
$this->labels = $this->stats->pluck('start')->toArray(); | ||
$this->values = $this->stats->pluck('value')->toArray(); | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('livewire.admin.resource-creation-stats-graph'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace App\Http\Livewire\Admin; | ||
|
||
use Livewire\Component; | ||
use App\Stats\UserRegistrationStats; | ||
|
||
class UserRegistrationStatsGraph extends Component | ||
{ | ||
public $stats; | ||
public $labels; | ||
public $values; | ||
|
||
public function mount() | ||
{ | ||
//UserRegistrationStats::set(random_int(1, 1000), now()->subDays(10)); | ||
$this->stats = UserRegistrationStats::query() | ||
->start(now()->subDays(10)) | ||
->end(now()->subSecond()) | ||
->groupByDay() | ||
->get(); | ||
$this->labels = $this->stats->pluck('start')->toArray(); | ||
$this->values = $this->stats->pluck('value')->toArray(); | ||
//dd($this->stats->pluck('value')->toArray()); | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('livewire.admin.user-registration-stats-graph'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace App\Stats; | ||
|
||
use Spatie\Stats\BaseStats; | ||
|
||
class ResourceCreationStats extends BaseStats | ||
{ | ||
/* | ||
public function getName() : string{ | ||
return 'my-custom-name'; // stats will be stored with using name `my-custom-name` | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace App\Stats; | ||
|
||
use Spatie\Stats\BaseStats; | ||
|
||
class UserRegistrationStats extends BaseStats | ||
{ | ||
/* | ||
public function getName() : string{ | ||
return 'my-custom-name'; // stats will be stored with using name `my-custom-name` | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
database/migrations/2022_01_06_195808_create_stats_tables.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateStatsTables extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('stats_events', function (Blueprint $table) { | ||
$table->id(); | ||
|
||
$table->string('name'); | ||
$table->string('type'); | ||
$table->bigInteger('value'); | ||
|
||
$table->timestamps(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.