mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 04:38:47 +08:00
FEATURE: the notice asking admins to get discussion started will update with live counts of topics and posts
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
require_dependency 'rate_limiter'
|
||||
|
||||
class AboutController < ApplicationController
|
||||
skip_before_filter :check_xhr, only: [:show]
|
||||
|
||||
@ -5,4 +7,13 @@ class AboutController < ApplicationController
|
||||
@about = About.new
|
||||
render_serialized(@about, AboutSerializer)
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
Reference in New Issue
Block a user