From 01a38f89a7a77cad571d9212b239c02fda63eb02 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 24 Apr 2024 10:09:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E4=BC=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?=E6=9C=88=E4=BB=BD=E7=BB=9F=E8=AE=A1=E8=BF=98=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/dashboards_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/admins/dashboards_controller.rb b/app/controllers/admins/dashboards_controller.rb index 6940ed1c..2d1320fc 100644 --- a/app/controllers/admins/dashboards_controller.rb +++ b/app/controllers/admins/dashboards_controller.rb @@ -18,8 +18,11 @@ class Admins::DashboardsController < Admins::BaseController # 活跃项目数 day_project_ids = (CommitLog.where(created_at: today).pluck(:project_id).uniq + Issue.where(created_on: today).pluck(:project_id).uniq).uniq - weekly_project_ids = (CommitLog.where(created_at: current_week).pluck(:project_id).uniq + Issue.where(created_on: current_week).pluck(:project_id).uniq).uniq - month_project_ids = (CommitLog.where(created_at: current_month).pluck(:project_id).uniq + Issue.where(created_on: current_month).pluck(:project_id).uniq).uniq + week_greater_id = CommitLog.where(created_at: current_week).limit(1)[0]&.id + weekly_project_ids = (CommitLog.where(created_at: current_week).where("id>= ?", week_greater_id).distinct.pluck(:project_id) + Issue.where(created_on: current_week).pluck(:project_id).uniq).uniq + #月份统计还需要优化 + month_greater_id = CommitLog.where(created_at: current_month).limit(1)[0]&.id + month_project_ids = (CommitLog.where(created_at: current_month).where("id>= ?", month_greater_id).distinct.pluck(:project_id) + Issue.where(created_on: current_month).pluck(:project_id).uniq).uniq @day_active_project_count = Project.where(updated_on: today).or(Project.where(id: day_project_ids)).count @weekly_active_project_count = Rails.cache.fetch("dashboardscontroller:weekly_active_project_count", expires_in: 10.minutes) do Project.where(updated_on: current_week).or(Project.where(id: weekly_project_ids)).count