diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/accounts_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/api/v1/accounts_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/api/v1/timelines_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 1 | ||||
-rw-r--r-- | app/controllers/tags_controller.rb | 3 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 4 | ||||
-rw-r--r-- | app/views/accounts/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/tags/show.html.haml | 2 |
8 files changed, 18 insertions, 11 deletions
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 5d2f4eee0..b0e5a8320 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -9,7 +9,8 @@ class AccountsController < ApplicationController def show respond_to do |format| format.html do - @statuses = @account.statuses.order('id desc').with_includes.with_counters.paginate(page: params[:page], per_page: 10) + @statuses = @account.statuses.order('id desc').paginate_by_max_id(20, params[:max_id || nil]) + @statuses = cache_collection(@statuses, Status) end format.atom do @@ -29,11 +30,11 @@ class AccountsController < ApplicationController end def followers - @followers = @account.followers.order('follows.created_at desc').paginate(page: params[:page], per_page: 6) + @followers = @account.followers.order('follows.created_at desc').paginate(page: params[:page], per_page: 12) end def following - @following = @account.following.order('follows.created_at desc').paginate(page: params[:page], per_page: 6) + @following = @account.following.order('follows.created_at desc').paginate(page: params[:page], per_page: 12) end private diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index 9a356196c..0abdfd9fa 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -47,7 +47,7 @@ class Api::V1::AccountsController < ApiController end def statuses - @statuses = @account.statuses.paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]).to_a + @statuses = @account.statuses.paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]) @statuses = cache_collection(@statuses, Status) set_maps(@statuses) diff --git a/app/controllers/api/v1/timelines_controller.rb b/app/controllers/api/v1/timelines_controller.rb index 89e54e2cf..9727797e5 100644 --- a/app/controllers/api/v1/timelines_controller.rb +++ b/app/controllers/api/v1/timelines_controller.rb @@ -7,7 +7,7 @@ class Api::V1::TimelinesController < ApiController respond_to :json def home - @statuses = Feed.new(:home, current_account).get(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]).to_a + @statuses = Feed.new(:home, current_account).get(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]) @statuses = cache_collection(@statuses) set_maps(@statuses) @@ -23,7 +23,7 @@ class Api::V1::TimelinesController < ApiController end def mentions - @statuses = Feed.new(:mentions, current_account).get(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]).to_a + @statuses = Feed.new(:mentions, current_account).get(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]) @statuses = cache_collection(@statuses) set_maps(@statuses) @@ -39,7 +39,7 @@ class Api::V1::TimelinesController < ApiController end def public - @statuses = Status.as_public_timeline(current_account).paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]).to_a + @statuses = Status.as_public_timeline(current_account).paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]) @statuses = cache_collection(@statuses) set_maps(@statuses) @@ -56,7 +56,7 @@ class Api::V1::TimelinesController < ApiController def tag @tag = Tag.find_by(name: params[:id].downcase) - @statuses = @tag.nil? ? [] : Status.as_tag_timeline(@tag, current_account).paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]).to_a + @statuses = @tag.nil? ? [] : Status.as_tag_timeline(@tag, current_account).paginate_by_max_id(DEFAULT_STATUSES_LIMIT, params[:max_id], params[:since_id]) @statuses = cache_collection(@statuses) set_maps(@statuses) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9722f86b5..fbe4af07c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -61,6 +61,7 @@ class ApplicationController < ActionController::Base def cache_collection(raw, klass) return raw unless klass.respond_to?(:with_includes) + raw = raw.select(:id, :updated_at).to_a if raw.is_a?(ActiveRecord::Relation) uncached_ids = [] cached_keys_with_value = Rails.cache.read_multi(*raw.map(&:cache_key)) diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index a6b359485..4a70b2a8f 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -4,6 +4,7 @@ class TagsController < ApplicationController layout 'public' def show - @statuses = Tag.find_by!(name: params[:id].downcase).statuses.order('id desc').with_includes.with_counters.paginate(page: params[:page], per_page: 10) + @statuses = Tag.find_by!(name: params[:id].downcase).statuses.order('id desc').paginate_by_max_id(20, params[:max_id] || nil) + @statuses = cache_collection(@statuses, Status) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index be82ff2fe..29c2c9120 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,4 +4,8 @@ module ApplicationHelper def active_nav_class(path) current_page?(path) ? 'active' : '' end + + def id_paginate(path, per_page, collection) + # todo + end end diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml index 563b43849..c04faa32f 100644 --- a/app/views/accounts/show.html.haml +++ b/app/views/accounts/show.html.haml @@ -14,4 +14,4 @@ .activity-stream = render partial: 'stream_entries/status', collection: @statuses, as: :status -= will_paginate @statuses, pagination_options += id_paginate account_url(@account), 20, @statuses diff --git a/app/views/tags/show.html.haml b/app/views/tags/show.html.haml index 0e6fd2db7..bfe5c0439 100644 --- a/app/views/tags/show.html.haml +++ b/app/views/tags/show.html.haml @@ -5,4 +5,4 @@ .activity-stream = render partial: 'stream_entries/status', collection: @statuses, as: :status, cached: true -= will_paginate @statuses, pagination_options += id_paginate tag_path, 20, @statuses |