mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-01-31 11:16:42 +01:00
Streamline calls to orderBy
This commit is contained in:
parent
3f85a1ca06
commit
3c43124446
16 changed files with 24 additions and 24 deletions
|
@ -59,7 +59,7 @@ class RebuildTags extends Command
|
|||
$track = Track::findOrFail($this->argument('trackId'));
|
||||
$tracks = [$track];
|
||||
} else {
|
||||
$tracks = Track::whereNotNull('published_at')->withTrashed()->orderBy('id', 'asc')->get();
|
||||
$tracks = Track::whereNotNull('published_at')->withTrashed()->orderBy('id')->get();
|
||||
}
|
||||
|
||||
$numberOfTracks = count($tracks);
|
||||
|
|
|
@ -71,7 +71,7 @@ class SyncPoniverseAccounts extends Command
|
|||
%current%/%max% [%bar%] %percent:3s%% %elapsed:6s%');
|
||||
|
||||
$usersToUpdate
|
||||
->orderBy('id', 'ASC')
|
||||
->orderBy('id')
|
||||
->chunk(100, function ($users) use ($progress) {
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
|
|
|
@ -134,7 +134,7 @@ class AlbumsController extends ApiControllerBase
|
|||
$perPage = 40;
|
||||
|
||||
$query
|
||||
->orderBy('title', 'asc')
|
||||
->orderBy('title')
|
||||
->skip(($page - 1) * $perPage)
|
||||
->take($perPage);
|
||||
$albums = [];
|
||||
|
@ -156,7 +156,7 @@ class AlbumsController extends ApiControllerBase
|
|||
$query = Album::summary()
|
||||
->with('cover', 'user.avatar')
|
||||
->where('user_id', $user->id)
|
||||
->orderBy('created_at', 'desc')->get();
|
||||
->orderByDesc('created_at')->get();
|
||||
$albums = [];
|
||||
|
||||
foreach ($query as $album) {
|
||||
|
|
|
@ -37,7 +37,7 @@ class AnnouncementsController extends Controller
|
|||
->whereNotNull('end_time')
|
||||
->where('start_time', '<', $currentDate)
|
||||
->where('end_time', '>', $currentDate)
|
||||
->orderBy('start_time', 'desc');
|
||||
->orderByDesc('start_time');
|
||||
|
||||
$announcement = $query->first();
|
||||
|
||||
|
@ -51,7 +51,7 @@ class AnnouncementsController extends Controller
|
|||
{
|
||||
$this->authorize('access-admin-area');
|
||||
|
||||
$announcements = Announcement::orderBy('start_time', 'desc')
|
||||
$announcements = Announcement::orderByDesc('start_time')
|
||||
->get();
|
||||
|
||||
return response()->json([
|
||||
|
@ -64,7 +64,7 @@ class AnnouncementsController extends Controller
|
|||
$this->authorize('access-admin-area');
|
||||
|
||||
$query = Announcement::where('id', '=', $genreId)
|
||||
->orderBy('start_time', 'desc');
|
||||
->orderByDesc('start_time');
|
||||
|
||||
$announcement = $query->first();
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ class ArtistsController extends ApiControllerBase
|
|||
|
||||
$query = Album::summary()
|
||||
->with('user')
|
||||
->orderBy('created_at', 'desc')
|
||||
->orderByDesc('created_at')
|
||||
->where('track_count', '>', 0)
|
||||
->whereUserId($user->id);
|
||||
|
||||
|
@ -148,7 +148,7 @@ class ArtistsController extends ApiControllerBase
|
|||
->userDetails()
|
||||
->whereUserId($user->id)
|
||||
->whereNotNull('published_at')
|
||||
->orderBy('created_at', 'desc')
|
||||
->orderByDesc('created_at')
|
||||
->take(20);
|
||||
|
||||
$latestTracks = [];
|
||||
|
@ -218,7 +218,7 @@ class ArtistsController extends ApiControllerBase
|
|||
|
||||
// The query results are ordered after they're counted
|
||||
// due to Postgres's behaviour when combining those two operations.
|
||||
$query->orderBy('display_name', 'asc');
|
||||
$query->orderBy('display_name');
|
||||
$perPage = 40;
|
||||
$query->skip(($page - 1) * $perPage)->take($perPage);
|
||||
$users = [];
|
||||
|
|
|
@ -56,7 +56,7 @@ class CommentsController extends ApiControllerBase
|
|||
}
|
||||
}
|
||||
|
||||
$query = Comment::where($column, '=', $id)->orderBy('created_at', 'desc')->with('user');
|
||||
$query = Comment::where($column, '=', $id)->orderByDesc('created_at')->with('user');
|
||||
$comments = [];
|
||||
|
||||
foreach ($query->get() as $comment) {
|
||||
|
|
|
@ -36,7 +36,7 @@ class DashboardController extends ApiControllerBase
|
|||
->userDetails()
|
||||
->explicitFilter()
|
||||
->published()
|
||||
->orderBy('published_at', 'desc')
|
||||
->orderByDesc('published_at')
|
||||
->take(30);
|
||||
|
||||
$recentQuery->whereHas('user', function ($q) {
|
||||
|
|
|
@ -37,7 +37,7 @@ class GenresController extends ApiControllerBase
|
|||
$genres = Genre::with(['trackCountRelation' => function ($query) {
|
||||
$query->withTrashed();
|
||||
}])
|
||||
->orderBy('name', 'asc')
|
||||
->orderBy('name')
|
||||
->get();
|
||||
|
||||
return response()->json([
|
||||
|
|
|
@ -167,7 +167,7 @@ class PlaylistsController extends ApiControllerBase
|
|||
$join->on('playlist_id', '=', 'playlists.id');
|
||||
})
|
||||
->where('pinned_playlists.user_id', '=', Auth::user()->id)
|
||||
->orderBy('title', 'asc')
|
||||
->orderBy('title')
|
||||
->select('playlists.*')
|
||||
->get();
|
||||
|
||||
|
@ -187,7 +187,7 @@ class PlaylistsController extends ApiControllerBase
|
|||
$query = Playlist::summary()
|
||||
->with('pins', 'tracks', 'tracks.cover')
|
||||
->where('user_id', $user->id)
|
||||
->orderBy('title', 'asc')
|
||||
->orderBy('title')
|
||||
->get();
|
||||
|
||||
$playlists = [];
|
||||
|
|
|
@ -37,7 +37,7 @@ class ShowSongsController extends ApiControllerBase
|
|||
$songs = ShowSong::with(['trackCountRelation' => function ($query) {
|
||||
$query->withTrashed();
|
||||
}])
|
||||
->orderBy('title', 'asc')
|
||||
->orderBy('title')
|
||||
->select('id', 'title', 'slug')
|
||||
->get();
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ class TracksController extends ApiControllerBase
|
|||
|
||||
public function getOwned(User $user)
|
||||
{
|
||||
$query = Track::summary()->where('user_id', $user->id)->orderBy('created_at', 'desc');
|
||||
$query = Track::summary()->where('user_id', $user->id)->orderByDesc('created_at');
|
||||
|
||||
$tracks = [];
|
||||
foreach ($query->get() as $track) {
|
||||
|
|
|
@ -150,7 +150,7 @@ class Album extends Model implements Searchable, Commentable, Favouritable
|
|||
|
||||
public function tracks()
|
||||
{
|
||||
return $this->hasMany(Track::class)->orderBy('track_number', 'asc');
|
||||
return $this->hasMany(Track::class)->orderBy('track_number');
|
||||
}
|
||||
|
||||
public function trackFiles()
|
||||
|
@ -162,7 +162,7 @@ class Album extends Model implements Searchable, Commentable, Favouritable
|
|||
|
||||
public function comments():HasMany
|
||||
{
|
||||
return $this->hasMany(Comment::class)->orderBy('created_at', 'desc');
|
||||
return $this->hasMany(Comment::class)->orderByDesc('created_at');
|
||||
}
|
||||
|
||||
public function activities():MorphMany
|
||||
|
|
|
@ -84,7 +84,7 @@ class Notification extends Model
|
|||
->where('notifications.user_id', $user->id)
|
||||
->whereNull('activities.deleted_at')
|
||||
->select('*', 'notifications.id as id')
|
||||
->orderBy('activities.created_at', 'DESC');
|
||||
->orderByDesc('activities.created_at');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ class Playlist extends Model implements Searchable, Commentable, Favouritable
|
|||
->withTimestamps();
|
||||
|
||||
if ($ordered) {
|
||||
$query = $query->orderBy('position', 'asc');
|
||||
$query = $query->orderBy('position');
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
@ -269,7 +269,7 @@ class Playlist extends Model implements Searchable, Commentable, Favouritable
|
|||
|
||||
public function comments():HasMany
|
||||
{
|
||||
return $this->hasMany(Comment::class)->orderBy('created_at', 'desc');
|
||||
return $this->hasMany(Comment::class)->orderByDesc('created_at');
|
||||
}
|
||||
|
||||
public function pins()
|
||||
|
|
|
@ -706,7 +706,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable
|
|||
|
||||
public function comments():HasMany
|
||||
{
|
||||
return $this->hasMany(Comment::class)->orderBy('created_at', 'desc');
|
||||
return $this->hasMany(Comment::class)->orderByDesc('created_at');
|
||||
}
|
||||
|
||||
public function favourites():HasMany
|
||||
|
|
|
@ -312,7 +312,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||
|
||||
public function comments():HasMany
|
||||
{
|
||||
return $this->hasMany(Comment::class, 'profile_id')->orderBy('created_at', 'desc');
|
||||
return $this->hasMany(Comment::class, 'profile_id')->orderByDesc('created_at');
|
||||
}
|
||||
|
||||
public function tracks()
|
||||
|
|
Loading…
Reference in a new issue