이 가이드는
/about페이지의 통계가 어떻게 계산되는지, 그리고 각 통계에 해당하는 Ruby 코드를 어디에서 찾을 수 있는지를 설명하기 위한 참고 자료입니다.
필요한 사용자 권한: 모든 사용자
About 페이지 통계
모든 Discourse 사이트에는 내장된 /about 페이지(예: Meta의 about 페이지)가 있으며, 여기에는 해당 사이트의 관리자 및 모더레이터 목록과 사이트 자체에 대한 몇 가지 통계가 포함되어 있습니다.
이 통계에는 관리자 및 모더레이터 계정을 포함한 모든 사용자가 포함됩니다. 일부 통계에는 익명 계정도 포함될 수 있습니다(사이트에서 활성화된 경우).
share anonymized statistics 사이트 설정이 활성화되어 있다면(기본적으로 이 설정은 활성화되어 있음) /about 페이지의 "Site Statistics"는 /about.json에서 가져올 수 있는 json 파일로 노출됩니다.
사이트가 공개(public) 상태라면, /about 페이지와 이러한 통계도 공개적으로 접근할 수 있습니다.
핵심 통계의 Ruby 코드는 다음 위치에 있습니다: discourse/lib/statistics.rb. 핵심 및 플러그인 통계를 조정하는
Stat모델은 discourse/app/models/stat.rb에 있습니다.
아래에는 각 통계가 어떻게 계산되는지에 대한 설명이 있습니다.
Topics
지정된 기간 내에 생성된 토픽의 수입니다. 이 통계에는 목록에 표시되지 않는 토픽(unlisted topics)이나 개인 메시지는 포함되지 않습니다.
topics = Topic.listable_topics
{
last_day: topics.where("created_at > ?", 1.day.ago).count,
"7_days": topics.where("created_at > ?", 7.days.ago).count,
"30_days": topics.where("created_at > ?", 30.days.ago).count,
count: topics.count,
}
Posts
지정된 기간 내에 생성된 게시물의 수입니다. 여기에는 개인 메시지도 포함되며 일반 게시물로 집계됩니다.
{
last_day: Post.where("created_at > ?", 1.day.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,
}
Sign-Ups
지정된 기간 내에 새 계정으로 가입한 유효한 사용자의 수입니다. "유효한 사용자(valid user)"란 real 사용자이면서 활성화되어 있고, 정지되지 않았으며, 침묵 상태가 아닌 사용자를 의미합니다. must approve users가 활성화되어 있다면 승인된 사용자만 집계됩니다.
def self.valid_users
users = User.real.activated.not_suspended.not_silenced
users = users.approved if SiteSetting.must_approve_users
users
end
{
last_day: valid_users.where("created_at > ?", 1.day.ago).count,
"7_days": valid_users.where("created_at > ?", 7.days.ago).count,
"30_days": valid_users.where("created_at > ?", 30.days.ago).count,
count: valid_users.count,
}
![]()
real사용자는 여기에서 정의됩니다: discourse/app/models/user.rb — 시스템/봇 사용자 및 익명 사용자 섀도 계정을 제외합니다.
Active Users
지정된 기간 내에 사이트를 방문한 유효한 사용자의 수입니다. Sign-Ups와 동일한 valid_users 필터를 사용합니다(비활성, 정지, 침묵 상태 사용자를 제외). 익명 모드 사용자는 포함되지만, 계정이 없는 사용자는 포함되지 않습니다.
{
last_day: valid_users.where("last_seen_at > ?", 1.day.ago).count,
"7_days": valid_users.where("last_seen_at > ?", 7.days.ago).count,
"30_days": valid_users.where("last_seen_at > ?", 30.days.ago).count,
}
Participating Users
지정된 기간 내에 어떤 동작(토픽 생성, 게시물 작성, 좋아요 등)을 수행한 유효한 사용자의 수입니다. 채팅이 활성화되어 있다면, 채팅 메시지를 보내거나 채팅 반응을 추가한 사용자도 집계됩니다.
{
last_day: participating_users_count(1.day.ago),
"7_days": participating_users_count(7.days.ago),
"30_days": participating_users_count(30.days.ago),
}
전체 구현은 discourse/lib/statistics.rb에 있습니다.
Likes
지정된 기간 내에 모든 토픽과 게시물이 받은 좋아요의 총 수입니다.
likes = UserAction.where(action_type: UserAction::LIKE)
{
last_day: likes.where("created_at > ?", 1.day.ago).count,
"7_days": likes.where("created_at > ?", 7.days.ago).count,
"30_days": likes.where("created_at > ?", 30.days.ago).count,
count: likes.count,
}
Visitors and EU Visitors
display eu visitor stats 사이트 설정이 활성화되어 있다면, about 페이지에는 추정 방문자 수(전체 및 EU 기반)도 표시됩니다. 이들은 로그인한 사용자의 방문 데이터와 페이지 뷰 비율에 기반한 추정 익명 방문자를 결합하여 계산됩니다.
전체 계산 방법은 discourse/lib/statistics.rb의
visitors및eu_visitors메서드를 참조하세요.
Chat Messages
모든 채팅 채널에서 전송된 채팅 메시지의 수입니다. 채팅이 활성화되어 있다면, 다음 통계도 등록됩니다: 채팅 사용자(메시지를 보낸 고유 사용자) 및 채팅 채널(공개 채널).
이러한 통계는 채팅 플러그인이 plugins/chat/plugin.rb의 register_stat를 통해 플러그인 통계로 등록합니다. 기본 쿼리는 plugins/chat/lib/chat/statistics.rb에 있습니다.
