about summary refs log tree commit diff
path: root/app/controllers/api/v1/timelines/public_controller.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2020-09-07 11:02:04 +0200
committerGitHub <noreply@github.com>2020-09-07 11:02:04 +0200
commite8bc187845b78e4a94894c69ecf930a524ad2056 (patch)
tree5d406773ebc580f361996222bd636bdaac108b2b /app/controllers/api/v1/timelines/public_controller.rb
parenta6121a159c5305ea9faa95743a50babb23ab41cd (diff)
Refactor how public and tag timelines are queried (#14728)
Diffstat (limited to 'app/controllers/api/v1/timelines/public_controller.rb')
-rw-r--r--app/controllers/api/v1/timelines/public_controller.rb29
1 files changed, 14 insertions, 15 deletions
diff --git a/app/controllers/api/v1/timelines/public_controller.rb b/app/controllers/api/v1/timelines/public_controller.rb
index 26d877b00..d253b744f 100644
--- a/app/controllers/api/v1/timelines/public_controller.rb
+++ b/app/controllers/api/v1/timelines/public_controller.rb
@@ -20,26 +20,25 @@ class Api::V1::Timelines::PublicController < Api::BaseController
   end
 
   def cached_public_statuses_page
-    cache_collection_paginated_by_id(
-      public_statuses,
-      Status,
-      limit_param(DEFAULT_STATUSES_LIMIT),
-      params_slice(:max_id, :since_id, :min_id)
-    )
+    cache_collection(public_statuses, Status)
   end
 
   def public_statuses
-    statuses = public_timeline_statuses
-
-    if truthy_param?(:only_media)
-      statuses.joins(:media_attachments).group(:id)
-    else
-      statuses
-    end
+    public_feed.get(
+      limit_param(DEFAULT_STATUSES_LIMIT),
+      params[:max_id],
+      params[:since_id],
+      params[:min_id]
+    )
   end
 
-  def public_timeline_statuses
-    Status.as_public_timeline(current_account, truthy_param?(:remote) ? :remote : truthy_param?(:local))
+  def public_feed
+    PublicFeed.new(
+      current_account,
+      local: truthy_param?(:local),
+      remote: truthy_param?(:remote),
+      only_media: truthy_param?(:only_media)
+    )
   end
 
   def insert_pagination_headers