pagination: refactor page limits.

Refactor page limits to a) be explicitly listed in the User class (not
hidden away in the Danbooru config) and b) explicitly depend on the
CurrentUser (not implicitly by way of Danbooru.config.max_numbered_pages).
This commit is contained in:
evazion
2021-01-11 20:09:52 -06:00
parent e9464d0ea5
commit ceeed1e692
7 changed files with 45 additions and 32 deletions

View File

@@ -380,6 +380,16 @@ class User < ApplicationRecord
end
end
def page_limit(level)
if level >= User::Levels::PLATINUM
5000
elsif level == User::Levels::GOLD
2000
else
1000
end
end
def tag_query_limit(level)
if level >= User::Levels::BUILDER
Float::INFINITY
@@ -484,6 +494,10 @@ class User < ApplicationRecord
@upload_limit ||= UploadLimit.new(self)
end
def page_limit
User.page_limit(level)
end
def tag_query_limit
User.tag_query_limit(level)
end