2015-08-28 05:28:33 +08:00
|
|
|
require_dependency 'rate_limiter'
|
|
|
|
|
2014-08-12 04:59:00 +08:00
|
|
|
class AboutController < ApplicationController
|
2016-03-08 04:28:02 +08:00
|
|
|
skip_before_filter :check_xhr, only: [:index]
|
2015-09-16 10:27:05 +08:00
|
|
|
before_filter :ensure_logged_in, only: [:live_post_counts]
|
2014-08-12 04:59:00 +08:00
|
|
|
|
|
|
|
def index
|
2017-03-08 15:42:24 +08:00
|
|
|
return redirect_to path('/login') if SiteSetting.login_required? && current_user.nil?
|
2016-03-08 04:28:02 +08:00
|
|
|
|
2017-03-08 15:42:24 +08:00
|
|
|
@about = About.new
|
2016-03-08 04:28:02 +08:00
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
|
|
|
render :index
|
|
|
|
end
|
|
|
|
format.json do
|
|
|
|
render_serialized(@about, AboutSerializer)
|
|
|
|
end
|
|
|
|
end
|
2014-08-12 04:59:00 +08:00
|
|
|
end
|
2015-08-28 05:28:33 +08:00
|
|
|
|
|
|
|
def live_post_counts
|
|
|
|
RateLimiter.new(current_user, "live_post_counts", 1, 10.minutes).performed! unless current_user.staff?
|
|
|
|
category_topic_ids = Category.pluck(:topic_id).compact!
|
|
|
|
public_topics = Topic.listable_topics.visible.secured(Guardian.new(nil)).where.not(id: category_topic_ids)
|
|
|
|
stats = { public_topic_count: public_topics.count }
|
|
|
|
stats[:public_post_count] = public_topics.sum(:posts_count) - stats[:public_topic_count]
|
|
|
|
render json: stats
|
|
|
|
end
|
2014-08-12 04:59:00 +08:00
|
|
|
end
|