Commit baaa838d by Tấn Trần Thanh

delete redundant includes models

parent 950db87a
......@@ -5,7 +5,7 @@ class WorkflowReportIssue < Issue
has_many :workflow_report_custom_values, class_name: 'WorkflowReportCustomValue', foreign_key: 'customized_id'
scope :raw_tasks_records, -> (year, month, project_ids) {
includes(:project, :workflow_report_version, :workflow_report_custom_values, :time_entries, :status, project: :enabled_modules)
includes(:time_entries, project: :enabled_modules)
.where.not(projects: { status: CLOSED_STATUS_PROJECT }, issues: { tracker_id: BUG_TRACKER_ID })
.where(projects: { id: project_ids }, enabled_modules: { name: 'time_tracking' })
.where(['((time_entries.spent_on IS NOT NULL AND time_entries.tyear = ? AND time_entries.tmonth = ?) OR (issues.closed_on BETWEEN ? AND ?))',
......
......@@ -42,7 +42,7 @@ module WorkflowReport
result[7].push(root_issue.status&.name.present? ? root_issue.status&.name : '')
sum_estimated_hours = issues.map(&:estimated_hours).compact.sum
result[8] << sum_estimated_hours.round(2)
actual_time = issues.map { |issue| issue.time_entries.sum(:hours) }.sum
actual_time = TimeEntry.where(issue_id: issue_ids).sum(:hours)
if actual_time.present?
result[9] << actual_time.round(2)
result[10] << (actual_time - sum_estimated_hours).round(2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment