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 { render :index }
|
2020-05-23 00:56:13 -04:00
|
|
|
format.json { render_json_dump(AboutSerializer.new(@about, scope: guardian)) }
|
2016-03-07 15:28:02 -05:00
|
|
|
end
|
2014-08-11 16:59:00 -04:00
|
|
|
end
|
2015-08-27 17:28:33 -04:00
|
|
|
|
|
|
|
def live_post_counts
|
|
|
|
unless current_user.staff?
|
|
|
|
RateLimiter.new(current_user, "live_post_counts", 1, 10.minutes).performed!
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2023-09-25 12:38:54 -04:00
|
|
|
category_topic_ids = Category.select(:topic_id).where.not(topic_id: nil)
|
2015-08-27 17:28:33 -04:00
|
|
|
public_topics =
|
2023-12-05 20:56:21 -05:00
|
|
|
Topic.listable_topics.visible.secured(Guardian.anon_user).where.not(id: category_topic_ids)
|
2015-08-27 17:28:33 -04:00
|
|
|
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
|