2014-08-12 04:59:00 +08:00
|
|
|
class About
|
|
|
|
include ActiveModel::Serialization
|
|
|
|
|
|
|
|
attr_accessor :moderators,
|
|
|
|
:admins
|
|
|
|
|
2014-08-12 06:15:35 +08:00
|
|
|
def version
|
|
|
|
Discourse::VERSION::STRING
|
|
|
|
end
|
|
|
|
|
|
|
|
def title
|
|
|
|
SiteSetting.title
|
|
|
|
end
|
|
|
|
|
|
|
|
def locale
|
|
|
|
SiteSetting.default_locale
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
SiteSetting.site_description
|
|
|
|
end
|
|
|
|
|
2014-08-12 04:59:00 +08:00
|
|
|
def moderators
|
2014-08-21 00:42:33 +08:00
|
|
|
@moderators ||= User.where(moderator: true, admin: false)
|
2014-08-12 06:15:35 +08:00
|
|
|
.where.not(id: Discourse::SYSTEM_USER_ID)
|
2014-08-12 04:59:00 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def admins
|
|
|
|
@admins ||= User.where(admin: true)
|
2014-08-12 06:15:35 +08:00
|
|
|
.where.not(id: Discourse::SYSTEM_USER_ID)
|
2014-08-12 04:59:00 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def stats
|
|
|
|
@stats ||= {
|
|
|
|
topic_count: Topic.listable_topics.count,
|
|
|
|
post_count: Post.count,
|
|
|
|
user_count: User.count,
|
|
|
|
topics_7_days: Topic.listable_topics.where('created_at > ?', 7.days.ago).count,
|
|
|
|
posts_7_days: Post.where('created_at > ?', 7.days.ago).count,
|
2014-08-12 06:15:35 +08:00
|
|
|
users_7_days: User.where('created_at > ?', 7.days.ago).count,
|
|
|
|
like_count: UserAction.where(action_type: UserAction::LIKE).count,
|
|
|
|
likes_7_days: UserAction.where(action_type: UserAction::LIKE)
|
|
|
|
.where("created_at > ?", 7.days.ago)
|
|
|
|
.count
|
2014-08-12 04:59:00 +08:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|