forked from e621ng/e621ng
changes to limit
This commit is contained in:
parent
493990dae1
commit
0cd009df24
@ -1,6 +1,6 @@
|
||||
class LegacyController < ApplicationController
|
||||
def posts
|
||||
@post_set = PostSets::Post.new(tag_query, params[:page])
|
||||
@post_set = PostSets::Post.new(tag_query, params[:page], params[:limit])
|
||||
@posts = @post_set.posts
|
||||
end
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
module PostSets
|
||||
class Post < Base
|
||||
attr_reader :tag_array, :page
|
||||
attr_reader :tag_array, :page, :per_page
|
||||
|
||||
def initialize(tags, page = 1)
|
||||
def initialize(tags, page = 1, per_page = nil)
|
||||
@tag_array = Tag.scan_query(tags)
|
||||
@page = page
|
||||
@per_page = (per_page || Post.records_per_page).to_i
|
||||
@per_page = 200 if @per_page > 200
|
||||
end
|
||||
|
||||
def tag_string
|
||||
@ -36,7 +38,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, :count => ::Post.fast_count(tag_string))
|
||||
@posts ||= ::Post.tag_match(tag_string).paginate(page, :count => ::Post.fast_count(tag_string), :limit => :per_page)
|
||||
rescue ::Post::SearchError
|
||||
@posts = ::Post.where("false")
|
||||
end
|
||||
|
@ -66,7 +66,7 @@ module Danbooru
|
||||
|
||||
def records_per_page
|
||||
# ugly hack but no easy way to pass this info down
|
||||
Thread.current["records_per_page"] || Danbooru.config.posts_per_page
|
||||
(@paginator_options[:limit] || Thread.current["records_per_page"] || Danbooru.config.posts_per_page).to_i
|
||||
end
|
||||
|
||||
# taken from kaminari (https://github.com/amatsuda/kaminari)
|
||||
|
Loading…
Reference in New Issue
Block a user