diff --git a/app/controllers/api/v1/timelines/group_controller.rb b/app/controllers/api/v1/timelines/group_controller.rb index 150ae398..3ff0e11c 100644 --- a/app/controllers/api/v1/timelines/group_controller.rb +++ b/app/controllers/api/v1/timelines/group_controller.rb @@ -33,18 +33,15 @@ class Api::V1::Timelines::GroupController < Api::BaseController def group_statuses statuses = nil if current_account - statuses = group_timeline_statuses.without_replies.paginate_by_id( + statuses = group_timeline_statuses.paginate_by_id( limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id) ).reject { |status| FeedManager.instance.filter?(:home, status, current_account.id) } else - statuses = group_timeline_statuses.without_replies.paginate_by_id( - limit_param(DEFAULT_STATUSES_LIMIT), - params_slice(:max_id, :since_id, :min_id) - ) + statuses = group_timeline_statuses.limit(DEFAULT_STATUSES_LIMIT) 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. status_ids = statuses.joins(:media_attachments).distinct(:id).pluck(:id) statuses.where(id: status_ids) @@ -54,7 +51,7 @@ class Api::V1::Timelines::GroupController < Api::BaseController end def group_timeline_statuses - GroupQueryService.new.call(@group) + Status.as_group_timeline(@group) end def insert_pagination_headers diff --git a/app/models/status.rb b/app/models/status.rb index 1ab95c9e..610151b2 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -304,6 +304,14 @@ class Status < ApplicationRecord where(group: group).without_replies 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) # direct timeline is mix of direct message from_me and to_me. # 2 queries are executed with pagination. diff --git a/app/services/group_query_service.rb b/app/services/group_query_service.rb deleted file mode 100644 index 82b9a556..00000000 --- a/app/services/group_query_service.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class GroupQueryService < BaseService - def call(group) - Status.as_group_timeline(group) - end -end