mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Guardian for hiding about stats (#9841)
This commit is contained in:
parent
cfff8b1f27
commit
bd57ae83f1
@ -64,50 +64,52 @@
|
|||||||
</section>
|
</section>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<section class="about stats">
|
{{#if model.can_see_about_stats}}
|
||||||
<h3>{{d-icon "far-chart-bar"}} {{i18n "about.stats"}}</h3>
|
<section class="about stats">
|
||||||
|
<h3>{{d-icon "far-chart-bar"}} {{i18n "about.stats"}}</h3>
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<th>{{i18n "about.stat.last_7_days"}}</th>
|
<th>{{i18n "about.stat.last_7_days"}}</th>
|
||||||
<th>{{i18n "about.stat.last_30_days"}}</th>
|
<th>{{i18n "about.stat.last_30_days"}}</th>
|
||||||
<th>{{i18n "about.stat.all_time"}}</th>
|
<th>{{i18n "about.stat.all_time"}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="title">{{i18n "about.topic_count"}}</td>
|
<td class="title">{{i18n "about.topic_count"}}</td>
|
||||||
<td>{{number model.stats.topics_7_days}}</td>
|
<td>{{number model.stats.topics_7_days}}</td>
|
||||||
<td>{{number model.stats.topics_30_days}}</td>
|
<td>{{number model.stats.topics_30_days}}</td>
|
||||||
<td>{{number model.stats.topic_count}}</td>
|
<td>{{number model.stats.topic_count}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{i18n "about.post_count"}}</td>
|
<td>{{i18n "about.post_count"}}</td>
|
||||||
<td>{{number model.stats.posts_7_days}}</td>
|
<td>{{number model.stats.posts_7_days}}</td>
|
||||||
<td>{{number model.stats.posts_30_days}}</td>
|
<td>{{number model.stats.posts_30_days}}</td>
|
||||||
<td>{{number model.stats.post_count}}</td>
|
<td>{{number model.stats.post_count}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{i18n "about.user_count"}}</td>
|
<td>{{i18n "about.user_count"}}</td>
|
||||||
<td>{{number model.stats.users_7_days}}</td>
|
<td>{{number model.stats.users_7_days}}</td>
|
||||||
<td>{{number model.stats.users_30_days}}</td>
|
<td>{{number model.stats.users_30_days}}</td>
|
||||||
<td>{{number model.stats.user_count}}</td>
|
<td>{{number model.stats.user_count}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{i18n "about.active_user_count"}}</td>
|
<td>{{i18n "about.active_user_count"}}</td>
|
||||||
<td>{{number model.stats.active_users_7_days}}</td>
|
<td>{{number model.stats.active_users_7_days}}</td>
|
||||||
<td>{{number model.stats.active_users_30_days}}</td>
|
<td>{{number model.stats.active_users_30_days}}</td>
|
||||||
<td>—</td>
|
<td>—</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{i18n "about.like_count"}}</td>
|
<td>{{i18n "about.like_count"}}</td>
|
||||||
<td>{{number model.stats.likes_7_days}}</td>
|
<td>{{number model.stats.likes_7_days}}</td>
|
||||||
<td>{{number model.stats.likes_30_days}}</td>
|
<td>{{number model.stats.likes_30_days}}</td>
|
||||||
<td>{{number model.stats.like_count}}</td>
|
<td>{{number model.stats.like_count}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#if contactInfo}}
|
{{#if contactInfo}}
|
||||||
<section class="about contact">
|
<section class="about contact">
|
||||||
|
@ -16,7 +16,7 @@ class AboutController < ApplicationController
|
|||||||
render :index
|
render :index
|
||||||
end
|
end
|
||||||
format.json do
|
format.json do
|
||||||
render_serialized(@about, AboutSerializer)
|
render_json_dump(AboutSerializer.new(@about, scope: guardian))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -21,7 +21,16 @@ class AboutSerializer < ApplicationSerializer
|
|||||||
:title,
|
:title,
|
||||||
:locale,
|
:locale,
|
||||||
:version,
|
:version,
|
||||||
:https
|
:https,
|
||||||
|
:can_see_about_stats
|
||||||
|
|
||||||
|
def can_see_about_stats
|
||||||
|
scope.can_see_about_stats?
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_stats?
|
||||||
|
can_see_about_stats
|
||||||
|
end
|
||||||
|
|
||||||
def stats
|
def stats
|
||||||
object.class.fetch_cached_stats || Jobs::AboutStats.new.execute({})
|
object.class.fetch_cached_stats || Jobs::AboutStats.new.execute({})
|
||||||
|
@ -493,6 +493,10 @@ class Guardian
|
|||||||
is_staff?
|
is_staff?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_see_about_stats?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def auth_token
|
def auth_token
|
||||||
if cookie = request&.cookies[Auth::DefaultCurrentUserProvider::TOKEN_COOKIE]
|
if cookie = request&.cookies[Auth::DefaultCurrentUserProvider::TOKEN_COOKIE]
|
||||||
UserAuthToken.hash_token(cookie)
|
UserAuthToken.hash_token(cookie)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
export default {
|
export default {
|
||||||
"about.json": {
|
"about.json": {
|
||||||
about: {
|
about: {
|
||||||
|
can_see_about_stats: true,
|
||||||
stats: {
|
stats: {
|
||||||
topic_count: 27480,
|
topic_count: 27480,
|
||||||
post_count: 490358,
|
post_count: 490358,
|
||||||
|
Loading…
Reference in New Issue
Block a user