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