Skip to content

Commit

Permalink
Add: Add db stat
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Oct 6, 2023
1 parent 5d7e032 commit 0ef78f5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 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 @@ -17,7 +17,11 @@ def data
discord: User.where.not(discord_id: nil).count
},
files:
FileResource.all.group_by(&:kind).transform_values(&:count)
FileResource
.all
.group_by(&:kind)
.transform_values(&:count),
db: ActiveRecord::Base.connection_pool.stat
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/i18n/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ admin:
private: "Private"
files: "Files"
storage: "Storage"
db: "Database"
db:
title: "Database"
connections: "{{busy}} busy, {{waiting}} waiting / {{size}} max"
sidekiq:
title: "Jobs (Sidekiq)"
description: "You can see the status of background jobs here."
Expand Down
4 changes: 3 additions & 1 deletion frontend/i18n/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ admin:
private: "非公開"
files: "ファイル"
storage: "ストレージ"
db: "データベースサイズ"
db:
title: "データベース"
connections: "使用中:{{busy}}、待機中:{{waiting}} / 最大:{{size}}"
sidekiq:
title: "ジョブ(Sidekiq)"
description: "バックグラウンドジョブの状態を確認できます。"
Expand Down
17 changes: 17 additions & 0 deletions frontend/pages/admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ const Admin: NextPage = () => {
discord: number
}
files: Record<string, number>
db: {
size: number
connections: number
busy: number
dead: number
idle: number
waiting: number
checkout_timeout: number
}
}
} | null>(null)

Expand Down Expand Up @@ -108,6 +117,14 @@ const Admin: NextPage = () => {
))}
</div>
</div>
<div className={statCard}>
<h2 className="text-xl font-bold">{t("stats.db.title")}</h2>
<div className="flex flex-col">
<p className="flex-1">
{t("stats.db.connections", data.stats.db)}
</p>
</div>
</div>
<div className={statCard}>
<h2 className="text-xl font-bold">{t("sidekiq.title")}</h2>
<p className="text-md">
Expand Down

0 comments on commit 0ef78f5

Please sign in to comment.