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