Skip to content

Commit

Permalink
Merge pull request #11448 from nanaya/per-page-default
Browse files Browse the repository at this point in the history
Increase default per page pagination limit
  • Loading branch information
peppy authored Aug 23, 2024
2 parents 91e1733 + a962899 commit 095d9e7
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/FollowsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private function indexComment()

private function indexForumTopic()
{
$topics = Topic::watchedByUser($this->user)->paginate(50);
$topics = Topic::watchedByUser($this->user)->paginate();
$topicReadStatus = TopicTrack::readStatus($this->user, $topics);
$topicWatchStatus = TopicWatch::watchStatus($this->user, $topics);

Expand Down Expand Up @@ -193,7 +193,7 @@ private function indexModding()
->visible()
->orderBy('last_notified', 'DESC')
->with('beatmapset')
->paginate(50);
->paginate();
$totalCount = $watches->total();
$unreadCount = $this->user->beatmapsetWatches()->visible()->unread()->count();
$openIssues = BeatmapDiscussion
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Forum/ForumsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function show($id)
->normal()
->showDeleted($showDeleted)
->recent(compact('sort', 'withReplies'))
->paginate(30);
->paginate();

$allTopics = array_merge($pinnedTopics->all(), $topics->all());
$topicReadStatus = TopicTrack::readStatus($user, $allTopics);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Forum/TopicLogsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function index($topicId)
$logs = $topic->logs()
->where('log_type', Log::LOG_FORUM_MOD)
->orderByDesc('log_time')
->paginate(30);
->paginate();

return ext_view('forum.topics.logs.index', compact('logs', 'topic'));
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Forum/TopicsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ private function getIndexParams($topic, $currentUser, $userCanModerate)
], ['null_missing' => true]);

$params['skip_layout'] = $params['skip_layout'] ?? false;
$params['limit'] = clamp($params['limit'] ?? 20, 1, 50);
$params['limit'] = clamp($params['limit'] ?? Post::PER_PAGE, 1, 50);

if ($userCanModerate) {
$params['with_deleted'] ??= ($currentUser->userProfileCustomization ?? UserProfileCustomization::DEFAULTS)['forum_posts_show_deleted'];
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Multiplayer/RoomsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use App\Exceptions\InvariantException;
use App\Http\Controllers\Controller as BaseController;
use App\Models\Model;
use App\Models\Multiplayer\Room;
use App\Transformers\Multiplayer\RoomTransformer;

Expand Down Expand Up @@ -114,7 +115,7 @@ public function join($roomId, $userId)

public function leaderboard($roomId)
{
$limit = clamp(get_int(request('limit')) ?? 50, 1, 50);
$limit = clamp(get_int(request('limit')) ?? Model::PER_PAGE, 1, 50);
$room = Room::findOrFail($roomId);

// leaderboard currently requires auth so auth()->check() is not required.
Expand Down Expand Up @@ -182,7 +183,7 @@ public function show($id)
}
$beatmaps = $playlistItemsQuery->with('beatmap.beatmapset.beatmaps')->get()->pluck('beatmap');
$beatmapsets = $beatmaps->pluck('beatmapset');
$highScores = $room->topScores()->paginate(50);
$highScores = $room->topScores()->paginate();
$spotlightRooms = Room::featured()->orderBy('id', 'DESC')->get();

return ext_view('multiplayer.rooms.show', [
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/RankingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Models\Beatmap;
use App\Models\Country;
use App\Models\CountryStatistics;
use App\Models\Model;
use App\Models\Spotlight;
use App\Models\User;
use App\Models\UserStatistics;
Expand All @@ -28,7 +29,7 @@ class RankingController extends Controller
private $friendsOnly;

const MAX_RESULTS = 10000;
const PAGE_SIZE = 50;
const PAGE_SIZE = Model::PER_PAGE;
const RANKING_TYPES = ['performance', 'charts', 'score', 'country'];
const SPOTLIGHT_TYPES = ['charts'];
// in display order
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Store/OrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function index()
$orders->where('status', '<>', 'incart');
}

$orders = $orders->paginate(20);
$orders = $orders->paginate();

return ext_view('store.orders.index', compact('orders'));
}
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ abstract class Model extends BaseModel
use HasFactory, Traits\FasterAttributes, Validatable;

const MAX_FIELD_LENGTHS = [];
const int PER_PAGE = 50;

protected $connection = 'mysql';
protected $guarded = [];
protected array $macros = [];
protected $perPage = self::PER_PAGE;
protected $primaryKeys;

public static function booted()
Expand Down

0 comments on commit 095d9e7

Please sign in to comment.