about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-08 20:16:11 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-08 20:20:45 +0100
commit6c4c84b161947cb11ad0451a39e26b25be4c93d5 (patch)
treefa2a6f4aaff71fcf76c745a57cb7732102814871 /app/controllers
parentfe57f6330f089d023f0fa4db7f7c8a51551d2ee9 (diff)
Distrubute statuses as a fan-out-on-write system, with optional precomputing
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/api/statuses_controller.rb6
-rw-r--r--app/controllers/home_controller.rb3
2 files changed, 6 insertions, 3 deletions
diff --git a/app/controllers/api/statuses_controller.rb b/app/controllers/api/statuses_controller.rb
index 82334a32f..04128537a 100644
--- a/app/controllers/api/statuses_controller.rb
+++ b/app/controllers/api/statuses_controller.rb
@@ -22,10 +22,12 @@ class Api::StatusesController < ApiController
   end
 
   def home
-    @statuses = Status.where(account: [current_user.account] + current_user.account.following).order('created_at desc')
+    feed      = Feed.new(:home, current_user.account)
+    @statuses = feed.get(20, (params[:offset] || 0).to_i)
   end
 
   def mentions
-    @statuses = Status.where(id: Mention.where(account: current_user.account).pluck(:status_id)).order('created_at desc')
+    feed      = Feed.new(:mentions, current_user.account)
+    @statuses = feed.get(20, (params[:offset] || 0).to_i)
   end
 end
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index 3a3d0ade4..294749a22 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -2,6 +2,7 @@ class HomeController < ApplicationController
   before_action :authenticate_user!
 
   def index
-    @statuses = Status.where(account: ([current_user.account] + current_user.account.following)).where('reblog_of_id IS NULL OR account_id != ?', current_user.account.id).order('created_at desc')
+    feed      = Feed.new(:home, current_user.account)
+    @statuses = feed.get(20, (params[:offset] || 0).to_i)
   end
 end