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