Upated GroupController, Removed GroupQueryService
• Upated: - GroupController • Removed: - GroupQueryService
This commit is contained in:
parent
b5fc61d2df
commit
7d4ff8df63
@ -33,18 +33,15 @@ class Api::V1::Timelines::GroupController < Api::BaseController
|
|||||||
def group_statuses
|
def group_statuses
|
||||||
statuses = nil
|
statuses = nil
|
||||||
if current_account
|
if current_account
|
||||||
statuses = group_timeline_statuses.without_replies.paginate_by_id(
|
statuses = group_timeline_statuses.paginate_by_id(
|
||||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
limit_param(DEFAULT_STATUSES_LIMIT),
|
||||||
params_slice(:max_id, :since_id, :min_id)
|
params_slice(:max_id, :since_id, :min_id)
|
||||||
).reject { |status| FeedManager.instance.filter?(:home, status, current_account.id) }
|
).reject { |status| FeedManager.instance.filter?(:home, status, current_account.id) }
|
||||||
else
|
else
|
||||||
statuses = group_timeline_statuses.without_replies.paginate_by_id(
|
statuses = group_timeline_statuses.limit(DEFAULT_STATUSES_LIMIT)
|
||||||
limit_param(DEFAULT_STATUSES_LIMIT),
|
|
||||||
params_slice(:max_id, :since_id, :min_id)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if truthy_param?(:only_media)
|
if truthy_param?(:only_media) && current_account
|
||||||
# `SELECT DISTINCT id, updated_at` is too slow, so pluck ids at first, and then select id, updated_at with ids.
|
# `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)
|
status_ids = statuses.joins(:media_attachments).distinct(:id).pluck(:id)
|
||||||
statuses.where(id: status_ids)
|
statuses.where(id: status_ids)
|
||||||
@ -54,7 +51,7 @@ class Api::V1::Timelines::GroupController < Api::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def group_timeline_statuses
|
def group_timeline_statuses
|
||||||
GroupQueryService.new.call(@group)
|
Status.as_group_timeline(@group)
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_pagination_headers
|
def insert_pagination_headers
|
||||||
|
@ -304,6 +304,14 @@ class Status < ApplicationRecord
|
|||||||
where(group: group).without_replies
|
where(group: group).without_replies
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def as_group_collection_timeline(groupIds)
|
||||||
|
where(
|
||||||
|
group: groupIds,
|
||||||
|
visibility: [:public, :unlisted, :private],
|
||||||
|
reply: false
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def as_direct_timeline(account, limit = 20, max_id = nil, since_id = nil, cache_ids = false)
|
def as_direct_timeline(account, limit = 20, max_id = nil, since_id = nil, cache_ids = false)
|
||||||
# direct timeline is mix of direct message from_me and to_me.
|
# direct timeline is mix of direct message from_me and to_me.
|
||||||
# 2 queries are executed with pagination.
|
# 2 queries are executed with pagination.
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class GroupQueryService < BaseService
|
|
||||||
def call(group)
|
|
||||||
Status.as_group_timeline(group)
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
x
Reference in New Issue
Block a user