mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-25 07:05:20 +00:00
Extract constants for controller LIMIT
queries (#32921)
This commit is contained in:
parent
16addf47c7
commit
c511cbcd6c
|
@ -5,6 +5,8 @@ module Admin
|
||||||
before_action :set_instances, only: :index
|
before_action :set_instances, only: :index
|
||||||
before_action :set_instance, except: :index
|
before_action :set_instance, except: :index
|
||||||
|
|
||||||
|
LOGS_LIMIT = 5
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize :instance, :index?
|
authorize :instance, :index?
|
||||||
preload_delivery_failures!
|
preload_delivery_failures!
|
||||||
|
@ -13,7 +15,7 @@ module Admin
|
||||||
def show
|
def show
|
||||||
authorize :instance, :show?
|
authorize :instance, :show?
|
||||||
@time_period = (6.days.ago.to_date...Time.now.utc.to_date)
|
@time_period = (6.days.ago.to_date...Time.now.utc.to_date)
|
||||||
@action_logs = Admin::ActionLogFilter.new(target_domain: @instance.domain).results.limit(5)
|
@action_logs = Admin::ActionLogFilter.new(target_domain: @instance.domain).results.limit(LOGS_LIMIT)
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
@ -5,6 +5,8 @@ class Api::V1::FeaturedTags::SuggestionsController < Api::BaseController
|
||||||
before_action :require_user!
|
before_action :require_user!
|
||||||
before_action :set_recently_used_tags, only: :index
|
before_action :set_recently_used_tags, only: :index
|
||||||
|
|
||||||
|
RECENT_TAGS_LIMIT = 10
|
||||||
|
|
||||||
def index
|
def index
|
||||||
render json: @recently_used_tags, each_serializer: REST::TagSerializer, relationships: TagRelationshipsPresenter.new(@recently_used_tags, current_user&.account_id)
|
render json: @recently_used_tags, each_serializer: REST::TagSerializer, relationships: TagRelationshipsPresenter.new(@recently_used_tags, current_user&.account_id)
|
||||||
end
|
end
|
||||||
|
@ -12,6 +14,6 @@ class Api::V1::FeaturedTags::SuggestionsController < Api::BaseController
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_recently_used_tags
|
def set_recently_used_tags
|
||||||
@recently_used_tags = Tag.suggestions_for_account(current_account).limit(10)
|
@recently_used_tags = Tag.suggestions_for_account(current_account).limit(RECENT_TAGS_LIMIT)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,8 @@ class Settings::FeaturedTagsController < Settings::BaseController
|
||||||
before_action :set_featured_tag, except: [:index, :create]
|
before_action :set_featured_tag, except: [:index, :create]
|
||||||
before_action :set_recently_used_tags, only: :index
|
before_action :set_recently_used_tags, only: :index
|
||||||
|
|
||||||
|
RECENT_TAGS_LIMIT = 10
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@featured_tag = FeaturedTag.new
|
@featured_tag = FeaturedTag.new
|
||||||
end
|
end
|
||||||
|
@ -38,7 +40,7 @@ class Settings::FeaturedTagsController < Settings::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_recently_used_tags
|
def set_recently_used_tags
|
||||||
@recently_used_tags = Tag.suggestions_for_account(current_account).limit(10)
|
@recently_used_tags = Tag.suggestions_for_account(current_account).limit(RECENT_TAGS_LIMIT)
|
||||||
end
|
end
|
||||||
|
|
||||||
def featured_tag_params
|
def featured_tag_params
|
||||||
|
|
|
@ -24,6 +24,8 @@ class Settings::ImportsController < Settings::BaseController
|
||||||
lists: false,
|
lists: false,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
RECENT_IMPORTS_LIMIT = 10
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@import = Form::Import.new(current_account: current_account)
|
@import = Form::Import.new(current_account: current_account)
|
||||||
end
|
end
|
||||||
|
@ -96,6 +98,6 @@ class Settings::ImportsController < Settings::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_recent_imports
|
def set_recent_imports
|
||||||
@recent_imports = current_account.bulk_imports.reorder(id: :desc).limit(10)
|
@recent_imports = current_account.bulk_imports.reorder(id: :desc).limit(RECENT_IMPORTS_LIMIT)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue