2014-08-11 15:59:00 -05:00
|
|
|
class About
|
|
|
|
include ActiveModel::Serialization
|
2015-07-06 23:52:19 -05:00
|
|
|
include StatsCacheable
|
2014-08-11 15:59:00 -05:00
|
|
|
|
|
|
|
attr_accessor :moderators,
|
|
|
|
:admins
|
|
|
|
|
2015-07-06 23:52:19 -05:00
|
|
|
def self.stats_cache_key
|
|
|
|
'about-stats'
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.fetch_stats
|
|
|
|
About.new.stats
|
|
|
|
end
|
|
|
|
|
2014-08-11 17:15:35 -05:00
|
|
|
def version
|
|
|
|
Discourse::VERSION::STRING
|
|
|
|
end
|
|
|
|
|
2014-11-24 00:54:17 -06:00
|
|
|
def https
|
|
|
|
SiteSetting.use_https
|
|
|
|
end
|
|
|
|
|
2014-08-11 17:15:35 -05:00
|
|
|
def title
|
|
|
|
SiteSetting.title
|
|
|
|
end
|
|
|
|
|
|
|
|
def locale
|
|
|
|
SiteSetting.default_locale
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
SiteSetting.site_description
|
|
|
|
end
|
|
|
|
|
2014-08-11 15:59:00 -05:00
|
|
|
def moderators
|
2014-08-20 11:42:33 -05:00
|
|
|
@moderators ||= User.where(moderator: true, admin: false)
|
2014-08-11 17:15:35 -05:00
|
|
|
.where.not(id: Discourse::SYSTEM_USER_ID)
|
2015-06-15 11:53:53 -05:00
|
|
|
.order(:username_lower)
|
2014-08-11 15:59:00 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def admins
|
|
|
|
@admins ||= User.where(admin: true)
|
2014-08-11 17:15:35 -05:00
|
|
|
.where.not(id: Discourse::SYSTEM_USER_ID)
|
2015-06-15 11:53:53 -05:00
|
|
|
.order(:username_lower)
|
2014-08-11 15:59:00 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def stats
|
|
|
|
@stats ||= {
|
|
|
|
topic_count: Topic.listable_topics.count,
|
|
|
|
post_count: Post.count,
|
2015-02-17 14:31:50 -06:00
|
|
|
user_count: User.real.count,
|
2014-08-11 15:59:00 -05:00
|
|
|
topics_7_days: Topic.listable_topics.where('created_at > ?', 7.days.ago).count,
|
2015-02-02 11:27:49 -06:00
|
|
|
topics_30_days: Topic.listable_topics.where('created_at > ?', 30.days.ago).count,
|
2014-08-11 15:59:00 -05:00
|
|
|
posts_7_days: Post.where('created_at > ?', 7.days.ago).count,
|
2015-02-02 11:27:49 -06:00
|
|
|
posts_30_days: Post.where('created_at > ?', 30.days.ago).count,
|
2014-08-11 17:15:35 -05:00
|
|
|
users_7_days: User.where('created_at > ?', 7.days.ago).count,
|
2015-02-02 11:27:49 -06:00
|
|
|
users_30_days: User.where('created_at > ?', 30.days.ago).count,
|
2015-01-30 16:23:52 -06:00
|
|
|
active_users_7_days: User.where('last_seen_at > ?', 7.days.ago).count,
|
2015-02-02 11:27:49 -06:00
|
|
|
active_users_30_days: User.where('last_seen_at > ?', 30.days.ago).count,
|
2014-08-11 17:15:35 -05:00
|
|
|
like_count: UserAction.where(action_type: UserAction::LIKE).count,
|
2015-02-02 11:27:49 -06:00
|
|
|
likes_7_days: UserAction.where(action_type: UserAction::LIKE).where("created_at > ?", 7.days.ago).count,
|
|
|
|
likes_30_days: UserAction.where(action_type: UserAction::LIKE).where("created_at > ?", 30.days.ago).count
|
2014-08-11 15:59:00 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|