Files
danbooru/app/controllers/post_votes_controller.rb
evazion 6424a4de74 Do full page counts on small index pages.
Normally we skip doing page counts on index pages when there aren't any
search filters. This is on the assumption that most index pages have
more than 1000 pages (20,000 results), so it's not worth counting them
exactly. This isn't always true, so here we turn on full counts on
certain index pages known to be small.
2019-10-28 15:18:54 -05:00

26 lines
570 B
Ruby

class PostVotesController < ApplicationController
before_action :voter_only
skip_before_action :api_check
respond_to :js, :json, :xml, :html
rescue_with PostVote::Error, status: 422
def index
@post_votes = PostVote.includes(:user, post: [:uploader]).paginated_search(params, count_pages: true)
respond_with(@post_votes)
end
def create
@post = Post.find(params[:post_id])
@post.vote!(params[:score])
respond_with(@post)
end
def destroy
@post = Post.find(params[:post_id])
@post.unvote!
respond_with(@post)
end
end