mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-22 01:38:49 -05:00
chore: streamline query builder orderBy calls with asc and desc arguments
This commit is contained in:
@@ -147,7 +147,7 @@ class UserController extends Controller
|
||||
public function posts(User $username): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
$results = Post::selectRaw('posts.id as id,posts.*')->with(['topic', 'user'])->leftJoin('topics', 'posts.topic_id', '=', 'topics.id')->where('posts.user_id', '=', $user->id)->orderBy('posts.created_at', 'desc')->paginate(25);
|
||||
$results = Post::selectRaw('posts.id as id,posts.*')->with(['topic', 'user'])->leftJoin('topics', 'posts.topic_id', '=', 'topics.id')->where('posts.user_id', '=', $user->id)->orderByDesc('posts.created_at')->paginate(25);
|
||||
|
||||
return \view('user.posts', [
|
||||
'route' => 'forum',
|
||||
@@ -1039,7 +1039,7 @@ class UserController extends Controller
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$groups = Group::where('level', '>', 0)->orderBy('level', 'desc')->get();
|
||||
$groups = Group::where('level', '>', 0)->orderByDesc('level')->get();
|
||||
|
||||
return \view('user.privacy', ['user' => $user, 'groups'=> $groups]);
|
||||
}
|
||||
@@ -1053,7 +1053,7 @@ class UserController extends Controller
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$groups = Group::where('level', '>', 0)->orderBy('level', 'desc')->get();
|
||||
$groups = Group::where('level', '>', 0)->orderByDesc('level')->get();
|
||||
|
||||
return \view('user.notification', ['user' => $user, 'groups'=> $groups]);
|
||||
}
|
||||
@@ -1600,13 +1600,13 @@ class UserController extends Controller
|
||||
$query->withAnyStatus();
|
||||
}])->leftJoin('torrents', 'torrents.info_hash', '=', 'history.info_hash')->where('actual_downloaded', '>', 0)
|
||||
->whereRaw('history.actual_downloaded > (torrents.size * ('.(\config('hitrun.buffer') / 100).'))')
|
||||
->where('history.user_id', '=', $user->id)->groupBy('history.info_hash')->orderBy('completed_at', 'desc')
|
||||
->where('history.user_id', '=', $user->id)->groupBy('history.info_hash')->orderByDesc('completed_at')
|
||||
->paginate(50);
|
||||
} else {
|
||||
$downloads = History::selectRaw('distinct(history.info_hash), max(torrents.id), max(history.completed_at) as completed_at, max(history.created_at) as created_at, max(history.id) as id, max(history.user_id) as user_id, max(history.seedtime) as seedtime, max(history.seeder) as seeder, max(torrents.size) as size,max(torrents.leechers) as leechers,max(torrents.seeders) as seeders,max(torrents.times_completed) as times_completed')->with(['torrent' => function ($query) {
|
||||
$query->withAnyStatus();
|
||||
}])->leftJoin('torrents', 'torrents.info_hash', '=', 'history.info_hash')
|
||||
->where('history.user_id', '=', $user->id)->groupBy('history.info_hash')->orderBy('completed_at', 'desc')
|
||||
->where('history.user_id', '=', $user->id)->groupBy('history.info_hash')->orderByDesc('completed_at')
|
||||
->paginate(50);
|
||||
}
|
||||
|
||||
@@ -1628,14 +1628,14 @@ class UserController extends Controller
|
||||
}])->selectRaw('distinct(history.info_hash), max(torrents.id), max(history.completed_at) as completed_at, max(history.created_at) as created_at, max(history.id) as id, max(history.user_id) as user_id, max(history.seedtime) as seedtime, max(history.seeder) as seeder, max(torrents.size) as size,max(torrents.leechers) as leechers,max(torrents.seeders) as seeders,max(torrents.times_completed) as times_completed')->leftJoin('torrents', 'torrents.info_hash', '=', 'history.info_hash')->where('actual_downloaded', '>', 0)
|
||||
->whereRaw('history.actual_downloaded > (torrents.size * ('.(\config('hitrun.buffer') / 100).'))')
|
||||
->where('history.user_id', '=', $user->id)
|
||||
->groupBy('history.info_hash')->orderBy('completed_at', 'desc')
|
||||
->groupBy('history.info_hash')->orderByDesc('completed_at')
|
||||
->paginate(50);
|
||||
} else {
|
||||
$downloads = History::with(['torrent' => function ($query) {
|
||||
$query->withAnyStatus();
|
||||
}])->selectRaw('distinct(history.info_hash), max(torrents.id), max(history.completed_at) as completed_at, max(history.created_at) as created_at, max(history.id) as id, max(history.user_id) as user_id, max(history.seedtime) as seedtime, max(history.seeder) as seeder, max(torrents.size) as size,max(torrents.leechers) as leechers,max(torrents.seeders) as seeders,max(torrents.times_completed) as times_completed')->leftJoin('torrents', 'torrents.info_hash', '=', 'history.info_hash')
|
||||
->where('history.user_id', '=', $user->id)
|
||||
->groupBy('history.info_hash')->orderBy('completed_at', 'desc')
|
||||
->groupBy('history.info_hash')->orderByDesc('completed_at')
|
||||
->paginate(50);
|
||||
}
|
||||
|
||||
@@ -1692,7 +1692,7 @@ class UserController extends Controller
|
||||
$query->withAnyStatus();
|
||||
}])->leftJoin('torrents', 'torrents.info_hash', '=', 'history.info_hash')
|
||||
->whereRaw('history.actual_downloaded > (torrents.size * ('.(\config('hitrun.buffer') / 100).'))')
|
||||
->where('history.user_id', '=', $user->id)->groupBy('history.info_hash')->orderBy('satisfied_at', 'desc')
|
||||
->where('history.user_id', '=', $user->id)->groupBy('history.info_hash')->orderByDesc('satisfied_at')
|
||||
->whereRaw('(history.seedtime < ? and history.immune != 1)', [\config('hitrun.seedtime')])
|
||||
->paginate(50);
|
||||
} else {
|
||||
@@ -1700,7 +1700,7 @@ class UserController extends Controller
|
||||
$query->withAnyStatus();
|
||||
}])->leftJoin('torrents', 'torrents.info_hash', '=', 'history.info_hash')
|
||||
->whereRaw('history.actual_downloaded > (torrents.size * ('.(\config('hitrun.buffer') / 100).'))')
|
||||
->where('history.user_id', '=', $user->id)->groupBy('history.info_hash')->orderBy('satisfied_at', 'desc')
|
||||
->where('history.user_id', '=', $user->id)->groupBy('history.info_hash')->orderByDesc('satisfied_at')
|
||||
->whereRaw('(history.seedtime < ? and history.immune != 1)', [\config('hitrun.seedtime')])
|
||||
->paginate(50);
|
||||
}
|
||||
@@ -1731,7 +1731,7 @@ class UserController extends Controller
|
||||
$history = History::with(['torrent' => function ($query) {
|
||||
$query->withAnyStatus();
|
||||
}])->selectRaw('distinct(history.id),max(history.info_hash) as info_hash,max(history.agent) as agent,max(history.uploaded) as uploaded,max(history.downloaded) as downloaded,max(history.seeder) as seeder,max(history.active) as active,max(history.actual_uploaded) as actual_uploaded,max(history.actual_downloaded) as actual_downloaded,max(history.seedtime) as seedtime,max(history.created_at) as created_at,max(history.updated_at) as updated_at,max(history.completed_at) as completed_at,max(history.immune) as immune,max(history.hitrun) as hitrun,max(history.prewarn) as prewarn,max(torrents.moderated_at) as moderated_at,max(torrents.slug) as slug,max(torrents.user_id) as user_id,max(torrents.name) as name,max(torrents.category_id) as category_id,max(torrents.size) as size,max(torrents.leechers) as leechers,max(torrents.seeders) as seeders,max(torrents.times_completed) as times_completed,max(torrents.status) as status')->leftJoin('torrents', 'torrents.info_hash', '=', 'history.info_hash')->where('history.user_id', '=', $user->id)->groupBy('history.id')
|
||||
->orderBy('created_at', 'DESC')->paginate(50);
|
||||
->orderByDesc('created_at')->paginate(50);
|
||||
|
||||
return \view('user.private.torrents', [
|
||||
'route' => 'torrents',
|
||||
@@ -1775,7 +1775,7 @@ class UserController extends Controller
|
||||
|
||||
$logger = 'user.private.uploads';
|
||||
$uploads = Torrent::with(['tips', 'thanks', 'category'])->selectRaw('distinct(torrents.id),max(torrents.moderated_at) as moderated_at,max(torrents.slug) as slug,max(torrents.user_id) as user_id,max(torrents.name) as name,max(torrents.category_id) as category_id,max(torrents.size) as size,max(torrents.leechers) as leechers,max(torrents.seeders) as seeders,max(torrents.times_completed) as times_completed,max(torrents.created_at) as created_at,max(torrents.status) as status,count(distinct thanks.id) as thanked_total,max(bt.tipped_total) as tipped_total')
|
||||
->withAnyStatus()->where('torrents.user_id', '=', $user->id)->leftJoin(DB::raw('(select distinct(bon_transactions.torrent_id),sum(bon_transactions.cost) as tipped_total from bon_transactions group by bon_transactions.torrent_id) as bt'), 'bt.torrent_id', '=', 'torrents.id')->leftJoin('thanks', 'thanks.torrent_id', 'torrents.id')->groupBy('torrents.id')->orderBy('created_at', 'DESC')->paginate(50);
|
||||
->withAnyStatus()->where('torrents.user_id', '=', $user->id)->leftJoin(DB::raw('(select distinct(bon_transactions.torrent_id),sum(bon_transactions.cost) as tipped_total from bon_transactions group by bon_transactions.torrent_id) as bt'), 'bt.torrent_id', '=', 'torrents.id')->leftJoin('thanks', 'thanks.torrent_id', 'torrents.id')->groupBy('torrents.id')->orderByDesc('created_at')->paginate(50);
|
||||
|
||||
return \view($logger, [
|
||||
'route' => 'uploads',
|
||||
@@ -1789,7 +1789,7 @@ class UserController extends Controller
|
||||
}
|
||||
|
||||
$logger = 'user.uploads';
|
||||
$uploads = Torrent::selectRaw('distinct(torrents.id),max(torrents.moderated_at) as moderated_at,max(torrents.slug) as slug,max(torrents.user_id) as user_id,max(torrents.name) as name,max(torrents.category_id) as category_id,max(torrents.size) as size,max(torrents.leechers) as leechers,max(torrents.seeders) as seeders,max(torrents.times_completed) as times_completed,max(torrents.created_at) as created_at,max(torrents.status) as status,count(distinct thanks.id) as thanked_total,sum(bon_transactions.cost) as tipped_total')->where('torrents.user_id', '=', $user->id)->where('torrents.status', '=', 1)->where('torrents.anon', '=', 0)->with(['tips', 'thanks'])->leftJoin('bon_transactions', 'bon_transactions.torrent_id', 'torrents.id')->leftJoin('thanks', 'thanks.torrent_id', 'torrents.id')->groupBy('torrents.id')->orderBy('created_at', 'DESC')->paginate(50);
|
||||
$uploads = Torrent::selectRaw('distinct(torrents.id),max(torrents.moderated_at) as moderated_at,max(torrents.slug) as slug,max(torrents.user_id) as user_id,max(torrents.name) as name,max(torrents.category_id) as category_id,max(torrents.size) as size,max(torrents.leechers) as leechers,max(torrents.seeders) as seeders,max(torrents.times_completed) as times_completed,max(torrents.created_at) as created_at,max(torrents.status) as status,count(distinct thanks.id) as thanked_total,sum(bon_transactions.cost) as tipped_total')->where('torrents.user_id', '=', $user->id)->where('torrents.status', '=', 1)->where('torrents.anon', '=', 0)->with(['tips', 'thanks'])->leftJoin('bon_transactions', 'bon_transactions.torrent_id', 'torrents.id')->leftJoin('thanks', 'thanks.torrent_id', 'torrents.id')->groupBy('torrents.id')->orderByDesc('created_at')->paginate(50);
|
||||
|
||||
return \view($logger, [
|
||||
'route' => 'uploads',
|
||||
@@ -1846,7 +1846,7 @@ class UserController extends Controller
|
||||
$seeds = Peer::with(['torrent' => function ($query) {
|
||||
$query->withAnyStatus();
|
||||
}])->selectRaw('distinct(torrents.info_hash),max(peers.id) as id,max(torrents.name) as name,max(torrents.seeders) as seeders,max(torrents.leechers) as leechers,max(torrents.times_completed) as times_completed,max(torrents.size) as size,max(history.info_hash) as history_info_hash,max(history.created_at) as history_created_at,max(torrents.id) as torrent_id,max(history.seedtime) as seedtime')->leftJoin('torrents', 'torrents.id', '=', 'peers.torrent_id')->leftJoin('history', 'history.info_hash', '=', 'torrents.info_hash')->where('peers.user_id', '=', $user->id)->whereRaw('history.user_id = ? and history.seeder = ?', [$user->id, 1])
|
||||
->where('peers.seeder', '=', 1)->orderBy('history_created_at', 'DESC')->groupBy('torrents.info_hash')
|
||||
->where('peers.seeder', '=', 1)->orderByDesc('history_created_at')->groupBy('torrents.info_hash')
|
||||
->paginate(50);
|
||||
|
||||
return \view('user.private.seeds', ['user' => $user,
|
||||
|
||||
Reference in New Issue
Block a user