[group_collection] Change to -my groups- timeline
This commit is contained in:
parent
3719a6cfd7
commit
958e8aad3a
|
@ -51,6 +51,7 @@ class Api::V1::StatusesController < Api::BaseController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
markdown = status_params[:markdown] unless status_params[:markdown] === status_params[:status]
|
markdown = status_params[:markdown] unless status_params[:markdown] === status_params[:status]
|
||||||
|
|
||||||
@status = PostStatusService.new.call(current_user.account,
|
@status = PostStatusService.new.call(current_user.account,
|
||||||
text: status_params[:status],
|
text: status_params[:status],
|
||||||
markdown: markdown,
|
markdown: markdown,
|
||||||
|
|
|
@ -64,13 +64,13 @@ class Api::V1::Timelines::GroupCollectionController < Api::BaseController
|
||||||
if @collection_type == 'featured'
|
if @collection_type == 'featured'
|
||||||
@groupIds = FetchGroupsService.new.call("featured")
|
@groupIds = FetchGroupsService.new.call("featured")
|
||||||
elsif @collection_type == 'member' && !current_account.nil?
|
elsif @collection_type == 'member' && !current_account.nil?
|
||||||
@groupIds = current_account.groups.pluck(:id)
|
# @groupIds = current_account.groups.pluck(:id)
|
||||||
|
return SortingQueryBuilder.new.call(@sort_type, @groupIds, params[:page], current_account.id, "group_collection")
|
||||||
end
|
end
|
||||||
|
|
||||||
if current_account
|
if current_account
|
||||||
SortingQueryBuilder.new.call(@sort_type, @groupIds, params[:page]).reject {|status|
|
SortingQueryBuilder.new.call(@sort_type, @groupIds, params[:page])
|
||||||
FeedManager.instance.filter?(:home, status, current_account.id)
|
# .reject {|status| FeedManager.instance.filter?(:home, status, current_account.id)}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
return []
|
return []
|
||||||
# page = [params[:page].to_i.abs, MIN_UNAUTHENTICATED_PAGES].min
|
# page = [params[:page].to_i.abs, MIN_UNAUTHENTICATED_PAGES].min
|
||||||
|
|
|
@ -1,24 +1,29 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class SortingQueryBuilder < BaseService
|
class SortingQueryBuilder < BaseService
|
||||||
def call(sort_type, group = nil, page = 1)
|
def call(sort_type, group = nil, page = 1, account_id = nil, source = nil)
|
||||||
limit = 20
|
limit = 20
|
||||||
|
|
||||||
min_likes = 5
|
min_likes = 5
|
||||||
min_reblogs = 2
|
min_reblogs = 2
|
||||||
min_replies = 1
|
min_replies = 1
|
||||||
date_limit = 5.years.ago
|
date_limit = 5.years.ago
|
||||||
|
pure_limit = "NOW() - INTERVAL '1 year'"
|
||||||
max_page = 8
|
max_page = 8
|
||||||
|
|
||||||
case sort_type
|
case sort_type
|
||||||
when 'hot'
|
when 'hot'
|
||||||
date_limit = 8.hours.ago
|
date_limit = 8.hours.ago
|
||||||
|
pure_limit = "NOW() - INTERVAL '8 hours'"
|
||||||
when 'top_today'
|
when 'top_today'
|
||||||
date_limit = 24.hours.ago
|
date_limit = 24.hours.ago
|
||||||
|
pure_limit = "NOW() - INTERVAL '24 hours'"
|
||||||
when 'top_weekly'
|
when 'top_weekly'
|
||||||
date_limit = 7.days.ago
|
date_limit = 7.days.ago
|
||||||
|
pure_limit = "NOW() - INTERVAL '7 days'"
|
||||||
when 'top_monthly'
|
when 'top_monthly'
|
||||||
date_limit = 30.days.ago
|
date_limit = 30.days.ago
|
||||||
|
pure_limit = "NOW() - INTERVAL '30 days'"
|
||||||
when 'top_yearly'
|
when 'top_yearly'
|
||||||
date_limit = 1.year.ago
|
date_limit = 1.year.ago
|
||||||
end
|
end
|
||||||
|
@ -39,7 +44,54 @@ class SortingQueryBuilder < BaseService
|
||||||
return []
|
return []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if source == 'group_collection'
|
||||||
|
return [] if account_id.nil?
|
||||||
|
query = "
|
||||||
|
select q.* from (
|
||||||
|
select s.*
|
||||||
|
from statuses s
|
||||||
|
join group_accounts ga
|
||||||
|
on s.group_id = ga.group_id
|
||||||
|
and ga.account_id = #{account_id} "
|
||||||
|
query += "
|
||||||
|
join status_stats ss
|
||||||
|
on s.id = ss.status_id " if sort_type != 'newest'
|
||||||
|
query += "
|
||||||
|
where "
|
||||||
|
query += "
|
||||||
|
ss.updated_at > #{pure_limit} " if sort_type == 'recent'
|
||||||
|
query += "
|
||||||
|
s.created_at > #{pure_limit} " if sort_type != 'recent'
|
||||||
|
query += "
|
||||||
|
and s.reply is false
|
||||||
|
and s.reblog_of_id is null "
|
||||||
|
if sort_type != 'newest'
|
||||||
|
query += "
|
||||||
|
order by ss.favourites_count desc, ss.reblogs_count desc, ss.replies_count desc "
|
||||||
|
else
|
||||||
|
query += "
|
||||||
|
order by s.created_at desc "
|
||||||
|
end
|
||||||
|
|
||||||
|
query += "limit #{limit} "
|
||||||
|
if page.to_i > 1
|
||||||
|
query += "offset #{page.to_i * limit}"
|
||||||
|
end
|
||||||
|
|
||||||
|
query += "
|
||||||
|
) q
|
||||||
|
left join custom_filters cf
|
||||||
|
on cf.account_id = #{account_id}
|
||||||
|
and q.text like '%' || cf.phrase || '%'
|
||||||
|
where cf.id is null
|
||||||
|
"
|
||||||
|
return Status.find_by_sql query
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if sort_type == 'newest'
|
if sort_type == 'newest'
|
||||||
|
|
||||||
query = Status.without_replies.without_reblogs
|
query = Status.without_replies.without_reblogs
|
||||||
query = query.with_public_visibility if group.nil?
|
query = query.with_public_visibility if group.nil?
|
||||||
query = query.where('statuses.created_at > ?', date_limit)
|
query = query.where('statuses.created_at > ?', date_limit)
|
||||||
|
|
|
@ -36,8 +36,8 @@ class HomeFeed < Feed
|
||||||
or s.account_id in (select target_account_id from follows where account_id = #{@id})
|
or s.account_id in (select target_account_id from follows where account_id = #{@id})
|
||||||
)
|
)
|
||||||
and s.account_id not in (select target_account_id from mutes where account_id = #{@id})
|
and s.account_id not in (select target_account_id from mutes where account_id = #{@id})
|
||||||
and reblog.account_id not in (select target_account_id from mutes where account_id = #{@id})
|
and (reblog.id is null or reblog.account_id not in (select target_account_id from mutes where account_id = #{@id}))
|
||||||
and reblog.account_id not in (select target_account_id from blocks where account_id = #{@id})
|
and (reblog.id is null or reblog.account_id not in (select target_account_id from blocks where account_id = #{@id}))
|
||||||
#{pagination_max}
|
#{pagination_max}
|
||||||
#{pagination_min}
|
#{pagination_min}
|
||||||
order by s.created_at desc
|
order by s.created_at desc
|
||||||
|
|
Loading…
Reference in New Issue