统计优化,月份统计还需要优化
This commit is contained in:
parent
9a7e9b4237
commit
01a38f89a7
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue