From e1e685746a193ee586ac251a60db10c69c5bcc23 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Fri, 30 Aug 2024 10:28:45 +0900 Subject: [PATCH] Improve: Improve admin page performance --- backend/app/controllers/api/admin_controller.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/app/controllers/api/admin_controller.rb b/backend/app/controllers/api/admin_controller.rb index 6c128ee..7d8c1db 100644 --- a/backend/app/controllers/api/admin_controller.rb +++ b/backend/app/controllers/api/admin_controller.rb @@ -17,10 +17,9 @@ def data discord: User.where.not(discord_id: nil).count }, files: - FileResource - .all - .group_by(&:kind) - .transform_values(&:count), + FileResource.kinds.transform_values do |kind| + FileResource.where(kind:).count + end, db: ActiveRecord::Base.connection_pool.stat } }