mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:25:35 +08:00
b3238bfc34
Now forums can enroll their sites to be showcased in the Discourse [Discover](https://discourse.org/discover) directory. Once they enable the site setting `include_in_discourse_discover` to enroll their forum the `CallDiscourseHub` job will ping the `api.discourse.org/api/discover/enroll` endpoint. Then the Discourse Hub will fetch the basic details from the forum and add it to the review queue. If the site is approved then the forum details will be displayed in the `/discover` page.
55 lines
1.7 KiB
Ruby
55 lines
1.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class Statistics
|
|
def self.active_users
|
|
{
|
|
last_day: User.where("last_seen_at > ?", 1.days.ago).count,
|
|
"7_days": User.where("last_seen_at > ?", 7.days.ago).count,
|
|
"30_days": User.where("last_seen_at > ?", 30.days.ago).count,
|
|
}
|
|
end
|
|
|
|
def self.likes
|
|
{
|
|
last_day:
|
|
UserAction.where(action_type: UserAction::LIKE).where("created_at > ?", 1.days.ago).count,
|
|
"7_days":
|
|
UserAction.where(action_type: UserAction::LIKE).where("created_at > ?", 7.days.ago).count,
|
|
"30_days":
|
|
UserAction.where(action_type: UserAction::LIKE).where("created_at > ?", 30.days.ago).count,
|
|
count: UserAction.where(action_type: UserAction::LIKE).count,
|
|
}
|
|
end
|
|
|
|
def self.posts
|
|
{
|
|
last_day: Post.where("created_at > ?", 1.days.ago).count,
|
|
"7_days": Post.where("created_at > ?", 7.days.ago).count,
|
|
"30_days": Post.where("created_at > ?", 30.days.ago).count,
|
|
count: Post.count,
|
|
}
|
|
end
|
|
|
|
def self.topics
|
|
{
|
|
last_day: Topic.listable_topics.where("created_at > ?", 1.days.ago).count,
|
|
"7_days": Topic.listable_topics.where("created_at > ?", 7.days.ago).count,
|
|
"30_days": Topic.listable_topics.where("created_at > ?", 30.days.ago).count,
|
|
count: Topic.listable_topics.count,
|
|
}
|
|
end
|
|
|
|
def self.users
|
|
{
|
|
last_day: User.real.where("created_at > ?", 1.days.ago).count,
|
|
"7_days": User.real.where("created_at > ?", 7.days.ago).count,
|
|
"30_days": User.real.where("created_at > ?", 30.days.ago).count,
|
|
count: User.real.count,
|
|
}
|
|
end
|
|
|
|
def self.discourse_discover
|
|
{ enrolled: SiteSetting.include_in_discourse_discover? }
|
|
end
|
|
end
|