mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-24 20:18:59 -05:00
refactor: preslash simple functions
- Add pre-slash to short named functions to improve performance by almost 30% - @see https://stackoverflow.com/questions/55419673/php7-adding-a-slash-to-all-standard-php-functions-php-cs-fixer-rule
This commit is contained in:
@@ -50,7 +50,7 @@ class HomeController extends Controller
|
||||
$user = $request->user();
|
||||
|
||||
// Latest Articles/News Block
|
||||
$articles = cache()->remember('latest_article', $expiresAt, fn () => Article::latest()->take(1)->get());
|
||||
$articles = \cache()->remember('latest_article', $expiresAt, fn () => Article::latest()->take(1)->get());
|
||||
foreach ($articles as $article) {
|
||||
$article->newNews = ($user->updated_at->subDays(3)->getTimestamp() < $article->created_at->getTimestamp()) ? 1 : 0;
|
||||
}
|
||||
@@ -58,25 +58,25 @@ class HomeController extends Controller
|
||||
// Latest Torrents Block
|
||||
$personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first();
|
||||
|
||||
$newest = cache()->remember('newest_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type'])
|
||||
$newest = \cache()->remember('newest_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest()
|
||||
->take(5)
|
||||
->get());
|
||||
|
||||
$seeded = cache()->remember('seeded_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type'])
|
||||
$seeded = \cache()->remember('seeded_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest('seeders')
|
||||
->take(5)
|
||||
->get());
|
||||
|
||||
$leeched = cache()->remember('leeched_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type'])
|
||||
$leeched = \cache()->remember('leeched_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get());
|
||||
|
||||
$dying = cache()->remember('dying_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type'])
|
||||
$dying = \cache()->remember('dying_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->where('seeders', '=', 1)
|
||||
->where('times_completed', '>=', 1)
|
||||
@@ -84,7 +84,7 @@ class HomeController extends Controller
|
||||
->take(5)
|
||||
->get());
|
||||
|
||||
$dead = cache()->remember('dead_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type'])
|
||||
$dead = \cache()->remember('dead_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->where('seeders', '=', 0)
|
||||
->latest('leechers')
|
||||
@@ -92,38 +92,38 @@ class HomeController extends Controller
|
||||
->get());
|
||||
|
||||
// Latest Topics Block
|
||||
$topics = cache()->remember('latest_topics', $expiresAt, fn () => Topic::with('forum')->latest()->take(5)->get());
|
||||
$topics = \cache()->remember('latest_topics', $expiresAt, fn () => Topic::with('forum')->latest()->take(5)->get());
|
||||
|
||||
// Latest Posts Block
|
||||
$posts = cache()->remember('latest_posts', $expiresAt, fn () => Post::with('topic', 'user')->latest()->take(5)->get());
|
||||
$posts = \cache()->remember('latest_posts', $expiresAt, fn () => Post::with('topic', 'user')->latest()->take(5)->get());
|
||||
|
||||
// Online Block
|
||||
$users = cache()->remember('online_users', $expiresAt, fn () => User::with('group', 'privacy')
|
||||
$users = \cache()->remember('online_users', $expiresAt, fn () => User::with('group', 'privacy')
|
||||
->withCount([
|
||||
'warnings' => function (Builder $query) {
|
||||
$query->whereNotNull('torrent')->where('active', '1');
|
||||
},
|
||||
])
|
||||
->where('last_action', '>', now()->subMinutes(5))
|
||||
->where('last_action', '>', \now()->subMinutes(5))
|
||||
->get());
|
||||
|
||||
$groups = cache()->remember('user-groups', $expiresAt, fn () => Group::select(['name', 'color', 'effect', 'icon'])->oldest('position')->get());
|
||||
$groups = \cache()->remember('user-groups', $expiresAt, fn () => Group::select(['name', 'color', 'effect', 'icon'])->oldest('position')->get());
|
||||
|
||||
// Featured Torrents Block
|
||||
$featured = cache()->remember('latest_featured', $expiresAt, fn () => FeaturedTorrent::with('torrent')->get());
|
||||
$featured = \cache()->remember('latest_featured', $expiresAt, fn () => FeaturedTorrent::with('torrent')->get());
|
||||
|
||||
// Latest Poll Block
|
||||
$poll = cache()->remember('latest_poll', $expiresAt, fn () => Poll::latest()->first());
|
||||
$poll = \cache()->remember('latest_poll', $expiresAt, fn () => Poll::latest()->first());
|
||||
|
||||
// Top Uploaders Block
|
||||
$uploaders = cache()->remember('top_uploaders', $expiresAt, fn () => Torrent::with('user')
|
||||
$uploaders = \cache()->remember('top_uploaders', $expiresAt, fn () => Torrent::with('user')
|
||||
->select(DB::raw('user_id, count(*) as value'))
|
||||
->groupBy('user_id')
|
||||
->latest('value')
|
||||
->take(10)
|
||||
->get());
|
||||
|
||||
$past_uploaders = cache()->remember('month_uploaders', $expiresAt, fn () => Torrent::with('user')
|
||||
$past_uploaders = \cache()->remember('month_uploaders', $expiresAt, fn () => Torrent::with('user')
|
||||
->where('created_at', '>', $current->copy()->subDays(30)->toDateTimeString())
|
||||
->select(DB::raw('user_id, count(*) as value'))
|
||||
->groupBy('user_id')
|
||||
@@ -134,7 +134,7 @@ class HomeController extends Controller
|
||||
$freeleech_tokens = FreeleechToken::where('user_id', $user->id)->get();
|
||||
$bookmarks = Bookmark::where('user_id', $user->id)->get();
|
||||
|
||||
return view('home.index', [
|
||||
return \view('home.index', [
|
||||
'user' => $user,
|
||||
'personal_freeleech' => $personal_freeleech,
|
||||
'users' => $users,
|
||||
|
||||
Reference in New Issue
Block a user