Skip to content

Commit

Permalink
Add: Verbose users data
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Aug 7, 2023
1 parent 890bb99 commit fa030a8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
6 changes: 5 additions & 1 deletion backend/app/controllers/api/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ def data
scheduled: Chart.where(visibility: :scheduled).count,
private: Chart.where(visibility: :private).count
},
users: User.count,
users: {
original: User.where(owner_id: nil).count,
alt: User.where.not(owner_id: nil).count,
discord: User.where.not(discord_id: nil).count
},
files:
FileResource.all.group_by(&:kind).transform_values(&:count)
}
Expand Down
7 changes: 6 additions & 1 deletion frontend/i18n/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ admin:
title: "Admin"
stats:
title: "Stats"
users: "Users"
users:
title: "Users"
total: "Total"
original: "Original"
alt: "Alt"
discord: "With Discord"
charts:
title: "Charts"
public: "Public"
Expand Down
7 changes: 6 additions & 1 deletion frontend/i18n/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ admin:
title: "管理者ページ"
stats:
title: "統計"
users: "ユーザー"
users:
title: "ユーザー"
total: "総数"
original: "本名義"
alt: "別名義"
discord: "Discord連携済"
charts:
title: "譜面"
public: "公開"
Expand Down
26 changes: 23 additions & 3 deletions frontend/pages/admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ const Admin: NextPage = () => {
private: number
}

users: number
users: {
original: number
alt: number
discord: number
}
files: Record<string, number>
}
} | null>(null)
Expand All @@ -55,8 +59,24 @@ const Admin: NextPage = () => {
<h1 className="text-2xl font-bold">{t("title")}</h1>
<div className="flex flex-col md:flex-row md:flex-wrap gap-4">
<div className={statCard}>
<h2 className="text-xl font-bold">{t("stats.users")}</h2>
<p className="text-4xl font-bold">{data.stats.users}</p>
<h2 className="text-xl font-bold">{t("stats.users.title")}</h2>
<p className="text-4xl font-bold">
{data.stats.users.original + data.stats.users.alt}
</p>
<div className="flex flex-col">
<div className="flex">
<p className="flex-1">{t("stats.users.original")}</p>
<p className="flex-1 text-right">{data.stats.users.original}</p>
</div>
<div className="flex">
<p className="flex-1">{t("stats.users.alt")}</p>
<p className="flex-1 text-right">{data.stats.users.alt}</p>
</div>
<div className="flex">
<p className="flex-1">{t("stats.users.discord")}</p>
<p className="flex-1 text-right">{data.stats.users.discord}</p>
</div>
</div>
</div>
<div className={statCard}>
<h2 className="text-xl font-bold">{t("stats.charts.title")}</h2>
Expand Down

0 comments on commit fa030a8

Please sign in to comment.