fix counts
This commit is contained in:
@@ -8,7 +8,7 @@ class PostsController < ApplicationController
|
|||||||
rescue_from ActiveRecord::RecordNotFound, :with => :rescue_exception
|
rescue_from ActiveRecord::RecordNotFound, :with => :rescue_exception
|
||||||
|
|
||||||
def index
|
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
|
@posts = @post_set.posts
|
||||||
respond_with(@posts) do |format|
|
respond_with(@posts) do |format|
|
||||||
format.atom
|
format.atom
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
module PostSets
|
module PostSets
|
||||||
class Favorite < Base
|
class Favorite < Base
|
||||||
attr_reader :user, :page, :favorites
|
attr_reader :user, :page, :favorites, :params
|
||||||
|
|
||||||
def initialize(user_id, page = 1, params = {})
|
def initialize(user_id, page = 1, params = {})
|
||||||
|
@params = params
|
||||||
@user = ::User.find(user_id)
|
@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
|
end
|
||||||
|
|
||||||
def tag_array
|
def tag_array
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
module PostSets
|
module PostSets
|
||||||
class Note < Post
|
class Note < Post
|
||||||
|
attr_reader :params
|
||||||
|
|
||||||
def initialize(params)
|
def initialize(params)
|
||||||
# don't call super because we don't want to repeat these queries
|
# don't call super because we don't want to repeat these queries
|
||||||
|
@params = params
|
||||||
@tag_array = Tag.scan_query(params[:tags])
|
@tag_array = Tag.scan_query(params[:tags])
|
||||||
@page = params[:page] || 1
|
@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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def limit
|
def limit
|
||||||
Danbooru.config.posts_per_page
|
CurrentUser.user.per_page
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_array
|
def tag_array
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def limit
|
def limit
|
||||||
25
|
CurrentUser.user.per_page
|
||||||
end
|
end
|
||||||
|
|
||||||
def min_date
|
def min_date
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class ForumPost < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def forum_topic_page
|
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
|
end
|
||||||
|
|
||||||
def is_original_post?
|
def is_original_post?
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class ForumTopic < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def last_page
|
def last_page
|
||||||
(posts.count / CurrentUser.user.per_page.to_f).ceil
|
(posts.count / Danbooru.config.posts_per_page.to_f).ceil
|
||||||
end
|
end
|
||||||
|
|
||||||
def presenter(forum_posts)
|
def presenter(forum_posts)
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ module Danbooru
|
|||||||
def option_for(key)
|
def option_for(key)
|
||||||
case key
|
case key
|
||||||
when :limit
|
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
|
if limit.to_i > 1_000
|
||||||
limit = 1_000
|
limit = 1_000
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user