Fixed issue in TagController
• Fixed: - issue in TagController
This commit is contained in:
parent
f5cf42bb60
commit
c43d1d38de
@ -8,7 +8,7 @@ class Api::V1::Timelines::TagController < Api::BaseController
|
|||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@statuses = load_statuses
|
@statuses = tagged_statuses
|
||||||
render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id)
|
render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -18,14 +18,6 @@ class Api::V1::Timelines::TagController < Api::BaseController
|
|||||||
@tag = Tag.find_normalized(params[:id])
|
@tag = Tag.find_normalized(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_statuses
|
|
||||||
cached_tagged_statuses
|
|
||||||
end
|
|
||||||
|
|
||||||
def cached_tagged_statuses
|
|
||||||
cache_collection tagged_statuses, Status
|
|
||||||
end
|
|
||||||
|
|
||||||
def tagged_statuses
|
def tagged_statuses
|
||||||
if @tag.nil?
|
if @tag.nil?
|
||||||
[]
|
[]
|
||||||
@ -35,13 +27,7 @@ class Api::V1::Timelines::TagController < Api::BaseController
|
|||||||
params_slice(:max_id, :since_id, :min_id)
|
params_slice(:max_id, :since_id, :min_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
if truthy_param?(:only_media)
|
statuses
|
||||||
# `SELECT DISTINCT id, updated_at` is too slow, so pluck ids at first, and then select id, updated_at with ids.
|
|
||||||
status_ids = statuses.joins(:media_attachments).distinct(:id).pluck(:id)
|
|
||||||
statuses.where(id: status_ids)
|
|
||||||
else
|
|
||||||
statuses
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user