mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-01-23 12:30:51 -06:00
refactor: closure to arrow function
This commit is contained in:
@@ -44,112 +44,74 @@ class StatsController extends Controller
|
||||
public function index()
|
||||
{
|
||||
// Total Members Count (All Groups)
|
||||
$all_user = cache()->remember('all_user', $this->expiresAt, function () {
|
||||
return User::withTrashed()->count();
|
||||
});
|
||||
$all_user = cache()->remember('all_user', $this->expiresAt, fn() => User::withTrashed()->count());
|
||||
|
||||
// Total Active Members Count (Not Validating, Banned, Disabled, Pruned)
|
||||
$active_user = cache()->remember('active_user', $this->expiresAt, function () {
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
$pruned_group = cache()->rememberForever('pruned_group', function () {
|
||||
return Group::where('slug', '=', 'pruned')->pluck('id');
|
||||
});
|
||||
$banned_group = cache()->rememberForever('banned_group', fn() => Group::where('slug', '=', 'banned')->pluck('id'));
|
||||
$validating_group = cache()->rememberForever('validating_group', fn() => Group::where('slug', '=', 'validating')->pluck('id'));
|
||||
$disabled_group = cache()->rememberForever('disabled_group', fn() => Group::where('slug', '=', 'disabled')->pluck('id'));
|
||||
$pruned_group = cache()->rememberForever('pruned_group', fn() => Group::where('slug', '=', 'pruned')->pluck('id'));
|
||||
|
||||
return User::whereNotIn('group_id', [$validating_group[0], $banned_group[0], $disabled_group[0], $pruned_group[0]])->count();
|
||||
});
|
||||
|
||||
// Total Disabled Members Count
|
||||
$disabled_user = cache()->remember('disabled_user', $this->expiresAt, function () {
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
$disabled_group = cache()->rememberForever('disabled_group', fn() => Group::where('slug', '=', 'disabled')->pluck('id'));
|
||||
|
||||
return User::where('group_id', '=', $disabled_group[0])->count();
|
||||
});
|
||||
|
||||
// Total Pruned Members Count
|
||||
$pruned_user = cache()->remember('pruned_user', $this->expiresAt, function () {
|
||||
$pruned_group = cache()->rememberForever('pruned_group', function () {
|
||||
return Group::where('slug', '=', 'pruned')->pluck('id');
|
||||
});
|
||||
$pruned_group = cache()->rememberForever('pruned_group', fn() => Group::where('slug', '=', 'pruned')->pluck('id'));
|
||||
|
||||
return User::onlyTrashed()->where('group_id', '=', $pruned_group[0])->count();
|
||||
});
|
||||
|
||||
// Total Banned Members Count
|
||||
$banned_user = cache()->remember('banned_user', $this->expiresAt, function () {
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$banned_group = cache()->rememberForever('banned_group', fn() => Group::where('slug', '=', 'banned')->pluck('id'));
|
||||
|
||||
return User::where('group_id', '=', $banned_group[0])->count();
|
||||
});
|
||||
|
||||
// Total Torrents Count
|
||||
$num_torrent = cache()->remember('num_torrent', $this->expiresAt, function () {
|
||||
return Torrent::count();
|
||||
});
|
||||
$num_torrent = cache()->remember('num_torrent', $this->expiresAt, fn() => Torrent::count());
|
||||
|
||||
// Total Categories With Torrent Count
|
||||
$categories = Category::withCount('torrents')->get()->sortBy('position');
|
||||
|
||||
// Total HD Count
|
||||
$num_hd = cache()->remember('num_hd', $this->expiresAt, function () {
|
||||
return Torrent::where('sd', '=', 0)->count();
|
||||
});
|
||||
$num_hd = cache()->remember('num_hd', $this->expiresAt, fn() => Torrent::where('sd', '=', 0)->count());
|
||||
|
||||
// Total SD Count
|
||||
$num_sd = cache()->remember('num_sd', $this->expiresAt, function () {
|
||||
return Torrent::where('sd', '=', 1)->count();
|
||||
});
|
||||
$num_sd = cache()->remember('num_sd', $this->expiresAt, fn() => Torrent::where('sd', '=', 1)->count());
|
||||
|
||||
// Total Torrent Size
|
||||
$torrent_size = cache()->remember('torrent_size', $this->expiresAt, function () {
|
||||
return Torrent::sum('size');
|
||||
});
|
||||
$torrent_size = cache()->remember('torrent_size', $this->expiresAt, fn() => Torrent::sum('size'));
|
||||
|
||||
// Total Seeders
|
||||
$num_seeders = cache()->remember('num_seeders', $this->expiresAt, function () {
|
||||
return Peer::where('seeder', '=', 1)->count();
|
||||
});
|
||||
$num_seeders = cache()->remember('num_seeders', $this->expiresAt, fn() => Peer::where('seeder', '=', 1)->count());
|
||||
|
||||
// Total Leechers
|
||||
$num_leechers = cache()->remember('num_leechers', $this->expiresAt, function () {
|
||||
return Peer::where('seeder', '=', 0)->count();
|
||||
});
|
||||
$num_leechers = cache()->remember('num_leechers', $this->expiresAt, fn() => Peer::where('seeder', '=', 0)->count());
|
||||
|
||||
// Total Peers
|
||||
$num_peers = cache()->remember('num_peers', $this->expiresAt, function () {
|
||||
return Peer::count();
|
||||
});
|
||||
$num_peers = cache()->remember('num_peers', $this->expiresAt, fn() => Peer::count());
|
||||
|
||||
//Total Upload Traffic Without Double Upload
|
||||
$actual_upload = cache()->remember('actual_upload', $this->expiresAt, function () {
|
||||
return History::sum('actual_uploaded');
|
||||
});
|
||||
$actual_upload = cache()->remember('actual_upload', $this->expiresAt, fn() => History::sum('actual_uploaded'));
|
||||
|
||||
//Total Upload Traffic With Double Upload
|
||||
$credited_upload = cache()->remember('credited_upload', $this->expiresAt, function () {
|
||||
return History::sum('uploaded');
|
||||
});
|
||||
$credited_upload = cache()->remember('credited_upload', $this->expiresAt, fn() => History::sum('uploaded'));
|
||||
|
||||
//Total Download Traffic Without Freeleech
|
||||
$actual_download = cache()->remember('actual_download', $this->expiresAt, function () {
|
||||
return History::sum('actual_downloaded');
|
||||
});
|
||||
$actual_download = cache()->remember('actual_download', $this->expiresAt, fn() => History::sum('actual_downloaded'));
|
||||
|
||||
//Total Download Traffic With Freeleech
|
||||
$credited_download = cache()->remember('credited_download', $this->expiresAt, function () {
|
||||
return History::sum('downloaded');
|
||||
});
|
||||
$credited_download = cache()->remember('credited_download', $this->expiresAt, fn() => History::sum('downloaded'));
|
||||
|
||||
//Total Up/Down Traffic without perks
|
||||
$actual_up_down = $actual_upload + $actual_download;
|
||||
@@ -189,18 +151,10 @@ class StatsController extends Controller
|
||||
*/
|
||||
public function uploaded()
|
||||
{
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
$pruned_group = cache()->rememberForever('pruned_group', function () {
|
||||
return Group::where('slug', '=', 'pruned')->pluck('id');
|
||||
});
|
||||
$banned_group = cache()->rememberForever('banned_group', fn() => Group::where('slug', '=', 'banned')->pluck('id'));
|
||||
$validating_group = cache()->rememberForever('validating_group', fn() => Group::where('slug', '=', 'validating')->pluck('id'));
|
||||
$disabled_group = cache()->rememberForever('disabled_group', fn() => Group::where('slug', '=', 'disabled')->pluck('id'));
|
||||
$pruned_group = cache()->rememberForever('pruned_group', fn() => Group::where('slug', '=', 'pruned')->pluck('id'));
|
||||
|
||||
// Fetch Top Uploaders
|
||||
$uploaded = User::latest('uploaded')->whereNotIn('group_id', [$validating_group[0], $banned_group[0], $disabled_group[0], $pruned_group[0]])->take(100)->get();
|
||||
@@ -217,18 +171,10 @@ class StatsController extends Controller
|
||||
*/
|
||||
public function downloaded()
|
||||
{
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
$pruned_group = cache()->rememberForever('pruned_group', function () {
|
||||
return Group::where('slug', '=', 'pruned')->pluck('id');
|
||||
});
|
||||
$banned_group = cache()->rememberForever('banned_group', fn() => Group::where('slug', '=', 'banned')->pluck('id'));
|
||||
$validating_group = cache()->rememberForever('validating_group', fn() => Group::where('slug', '=', 'validating')->pluck('id'));
|
||||
$disabled_group = cache()->rememberForever('disabled_group', fn() => Group::where('slug', '=', 'disabled')->pluck('id'));
|
||||
$pruned_group = cache()->rememberForever('pruned_group', fn() => Group::where('slug', '=', 'pruned')->pluck('id'));
|
||||
|
||||
// Fetch Top Downloaders
|
||||
$downloaded = User::latest('downloaded')->whereNotIn('group_id', [$validating_group[0], $banned_group[0], $disabled_group[0], $pruned_group[0]])->take(100)->get();
|
||||
@@ -284,18 +230,10 @@ class StatsController extends Controller
|
||||
*/
|
||||
public function bankers()
|
||||
{
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
$pruned_group = cache()->rememberForever('pruned_group', function () {
|
||||
return Group::where('slug', '=', 'pruned')->pluck('id');
|
||||
});
|
||||
$banned_group = cache()->rememberForever('banned_group', fn() => Group::where('slug', '=', 'banned')->pluck('id'));
|
||||
$validating_group = cache()->rememberForever('validating_group', fn() => Group::where('slug', '=', 'validating')->pluck('id'));
|
||||
$disabled_group = cache()->rememberForever('disabled_group', fn() => Group::where('slug', '=', 'disabled')->pluck('id'));
|
||||
$pruned_group = cache()->rememberForever('pruned_group', fn() => Group::where('slug', '=', 'pruned')->pluck('id'));
|
||||
|
||||
// Fetch Top Bankers
|
||||
$bankers = User::latest('seedbonus')->whereNotIn('group_id', [$validating_group[0], $banned_group[0], $disabled_group[0], $pruned_group[0]])->take(100)->get();
|
||||
|
||||
Reference in New Issue
Block a user