2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-08-11 15:59:00 -05:00
|
|
|
class AboutController < ApplicationController
|
2018-01-31 22:17:59 -06:00
|
|
|
|
|
|
|
requires_login only: [:live_post_counts]
|
|
|
|
|
2017-08-30 23:06:56 -05:00
|
|
|
skip_before_action :check_xhr, only: [:index]
|
2014-08-11 15:59:00 -05:00
|
|
|
|
|
|
|
def index
|
2017-03-08 01:42:24 -06:00
|
|
|
return redirect_to path('/login') if SiteSetting.login_required? && current_user.nil?
|
2016-03-07 14:28:02 -06:00
|
|
|
|
2019-07-31 08:46:58 -05:00
|
|
|
@about = About.new(current_user)
|
2018-11-27 10:19:59 -06:00
|
|
|
@title = "#{I18n.t("js.about.simple_title")} - #{SiteSetting.title}"
|
2016-03-07 14:28:02 -06:00
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
|
|
|
render :index
|
|
|
|
end
|
|
|
|
format.json do
|
2020-05-22 22:25:56 -05:00
|
|
|
render_serialized(@about, AboutSerializer)
|
2016-03-07 14:28:02 -06:00
|
|
|
end
|
|
|
|
end
|
2014-08-11 15:59:00 -05:00
|
|
|
end
|
2015-08-27 16:28:33 -05: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-11 15:59:00 -05:00
|
|
|
end
|