forked from e621ng/e621ng
use fast count in post paginator
This commit is contained in:
parent
4a5728e770
commit
a344fdbfe6
@ -32,7 +32,7 @@ module PostSets
|
||||
raise SearchError.new("Upgrade your account to search more than two tags at once")
|
||||
end
|
||||
|
||||
@posts ||= ::Post.tag_match(tag_string).paginate(page)
|
||||
@posts ||= ::Post.tag_match(tag_string).paginate(page, :count => Post.fast_count(tag_string))
|
||||
rescue ::Post::SearchError
|
||||
@posts = ::Post.where("false")
|
||||
end
|
||||
|
@ -6,7 +6,9 @@ module Danbooru
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
module ClassMethods
|
||||
def paginate(page)
|
||||
def paginate(page, options = {})
|
||||
@paginator_options = options
|
||||
|
||||
if use_sequential_paginator?(page)
|
||||
paginate_sequential(page)
|
||||
else
|
||||
@ -69,6 +71,8 @@ module Danbooru
|
||||
|
||||
# taken from kaminari (https://github.com/amatsuda/kaminari)
|
||||
def total_count
|
||||
return @paginator_options[:count] if @paginator_options[:count]
|
||||
|
||||
c = except(:offset, :limit, :order)
|
||||
c = c.reorder(nil)
|
||||
c = c.count
|
||||
|
Loading…
Reference in New Issue
Block a user