forked from e621ng/e621ng
fix counts
This commit is contained in:
parent
6f5c29df37
commit
ee1a70033c
@ -8,7 +8,7 @@ class PostsController < ApplicationController
|
||||
rescue_from ActiveRecord::RecordNotFound, :with => :rescue_exception
|
||||
|
||||
def index
|
||||
@post_set = PostSets::Post.new(tag_query, params[:page], params[:limit])
|
||||
@post_set = PostSets::Post.new(tag_query, params[:page], params[:limit] || CurrentUser.user.per_page)
|
||||
@posts = @post_set.posts
|
||||
respond_with(@posts) do |format|
|
||||
format.atom
|
||||
|
@ -1,10 +1,15 @@
|
||||
module PostSets
|
||||
class Favorite < Base
|
||||
attr_reader :user, :page, :favorites
|
||||
attr_reader :user, :page, :favorites, :params
|
||||
|
||||
def initialize(user_id, page = 1, params = {})
|
||||
@params = params
|
||||
@user = ::User.find(user_id)
|
||||
@favorites = ::Favorite.for_user(user.id).paginate(page, :limit => params[:limit]).order("favorites.id desc")
|
||||
@favorites = ::Favorite.for_user(user.id).paginate(page, :limit => limit).order("favorites.id desc")
|
||||
end
|
||||
|
||||
def limit
|
||||
params[:limit] || CurrentUser.user.per_page
|
||||
end
|
||||
|
||||
def tag_array
|
||||
|
@ -1,10 +1,17 @@
|
||||
module PostSets
|
||||
class Note < Post
|
||||
attr_reader :params
|
||||
|
||||
def initialize(params)
|
||||
# don't call super because we don't want to repeat these queries
|
||||
@params = params
|
||||
@tag_array = Tag.scan_query(params[:tags])
|
||||
@page = params[:page] || 1
|
||||
@posts = ::Post.tag_match(tag_string).has_notes.paginate(page, :limit => params[:limit]).reorder("last_noted_at desc")
|
||||
@posts = ::Post.tag_match(tag_string).has_notes.paginate(page, :limit => limit).reorder("last_noted_at desc")
|
||||
end
|
||||
|
||||
def limit
|
||||
params[:limit] || CurrentUser.user.per_page
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -16,7 +16,7 @@ module PostSets
|
||||
end
|
||||
|
||||
def limit
|
||||
Danbooru.config.posts_per_page
|
||||
CurrentUser.user.per_page
|
||||
end
|
||||
|
||||
def tag_array
|
||||
|
@ -12,7 +12,7 @@ module PostSets
|
||||
end
|
||||
|
||||
def limit
|
||||
25
|
||||
CurrentUser.user.per_page
|
||||
end
|
||||
|
||||
def min_date
|
||||
|
@ -120,7 +120,7 @@ class ForumPost < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def forum_topic_page
|
||||
((ForumPost.where("topic_id = ? and created_at <= ?", topic_id, created_at).count) / CurrentUser.user.per_page.to_f).ceil
|
||||
((ForumPost.where("topic_id = ? and created_at <= ?", topic_id, created_at).count) / Danbooru.config.posts_per_page.to_f).ceil
|
||||
end
|
||||
|
||||
def is_original_post?
|
||||
|
@ -56,7 +56,7 @@ class ForumTopic < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def last_page
|
||||
(posts.count / CurrentUser.user.per_page.to_f).ceil
|
||||
(posts.count / Danbooru.config.posts_per_page.to_f).ceil
|
||||
end
|
||||
|
||||
def presenter(forum_posts)
|
||||
|
@ -81,7 +81,7 @@ module Danbooru
|
||||
def option_for(key)
|
||||
case key
|
||||
when :limit
|
||||
limit = @paginator_options.try(:[], :limit) || CurrentUser.user.per_page
|
||||
limit = @paginator_options.try(:[], :limit) || Danbooru.config.posts_per_page
|
||||
if limit.to_i > 1_000
|
||||
limit = 1_000
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user