Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinecraft committed Nov 16, 2024
1 parent e2c7f39 commit ed1d0fb
Show file tree
Hide file tree
Showing 195 changed files with 1,925 additions and 1,853 deletions.
3 changes: 3 additions & 0 deletions app/Enums/ServerVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @method static static v1_18()
* @method static static v1_19()
* @method static static v1_20()
* @method static static v1_21()
*/
final class ServerVersion extends Enum
{
Expand All @@ -34,4 +35,6 @@ final class ServerVersion extends Enum
const v1_19 = '1.19';

const v1_20 = '1.20';

const v1_21 = '1.21';
}
8 changes: 4 additions & 4 deletions app/Http/Controllers/Admin/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public function index(Request $request)
$kpiUserCreatedForInterval = User::where('created_at', '>=', Carbon::now()->subDays(7))->count();
$totalUsersMinusInterval = $kpiTotalUsers - $kpiUserCreatedForInterval ?: 1;
$kpiTotalUserPercent = $kpiTotalUsers !== 0 ? ($kpiUserCreatedForInterval / $totalUsersMinusInterval) * 100 : 0;
$kpiUserLastSeenForInterval = User::where('last_login_at', '>=', Carbon::now()->subDays(7))->count();
$kpiTotalVerifiedUsers = User::isVerified(true)->count();

// KPI for total players
$kpiTotalPlayers = Player::fastCount();
$kpiPlayerCreatedForInterval = Player::where('created_at', '>=', Carbon::now()->subDays(7))->count();
$totalPlayersMinusInterval = $kpiTotalPlayers - $kpiPlayerCreatedForInterval ?: 1;
$kpiTotalPlayersPercent = $kpiTotalPlayers !== 0 ? ($kpiPlayerCreatedForInterval / $totalPlayersMinusInterval) * 100 : 0;
$kpiPlayerLastSeenForInterval = Player::where('last_seen_at', '>=', Carbon::now()->subDays(7))->count();
$kpiTotalLinkedPlayers = Player::whereHas('users')->count();

// KPI for total posts
$kpiTotalPosts = Post::fastCount();
Expand All @@ -49,13 +49,13 @@ public function index(Request $request)

$responseData = [
'kpiTotalUsers' => $kpiTotalUsers,
'kpiTotalVerifiedUsers' => $kpiTotalVerifiedUsers,
'kpiUserCreatedForInterval' => $kpiUserCreatedForInterval,
'kpiUserLastSeenForInterval' => $kpiUserLastSeenForInterval,
'kpiTotalUserPercent' => $kpiTotalUserPercent,

'kpiTotalPlayers' => $kpiTotalPlayers,
'kpiTotalLinkedPlayers' => $kpiTotalLinkedPlayers,
'kpiPlayerCreatedForInterval' => $kpiPlayerCreatedForInterval,
'kpiPlayerLastSeenForInterval' => $kpiPlayerLastSeenForInterval,
'kpiTotalPlayersPercent' => $kpiTotalPlayersPercent,

'kpiTotalFailedJobs' => $kpiTotalFailedJobs,
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/Admin/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@ public function index()
'country.name',
'discord_user_id',
AllowedFilter::custom('q', new FilterMultipleFields(['name', 'email', 'username', 'discord_user_id'])),
AllowedFilter::scope('is_verified'),
])
->allowedSorts(['id', 'name', 'email', 'username', 'created_at', 'updated_at', 'country_id', 'last_login_at'])
->defaultSort('id')
->paginate($perPage)
->withQueryString();

$countries = Country::select(['id', 'name'])->get()->pluck('name');
$roles = Role::select(['id', 'display_name'])->pluck('display_name');

return Inertia::render('Admin/User/IndexUser', [
'countries' => $countries,
'roles' => $roles,
'users' => $users,
'filters' => request()->all(['perPage', 'sort', 'filter']),
]);
Expand Down
5 changes: 5 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,4 +425,9 @@ public function routeNotificationForDiscord()
{
return $this->discord_private_channel_id;
}

public function scopeIsVerified($query, $bool = true)
{
return $query->where('verified_at', $bool ? '!=' : '=', null);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ed1d0fb

Please sign in to comment.