Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

eager load data required for timesheet

ulferts8dac805b0a65
diff --git a/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rb b/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rb
index f3dc48e0298..4c2735ab7d5 100644
--- a/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rb
+++ b/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rb
@@ -106,11 +106,14 @@ class CostQuery::PDF::TimesheetGenerator
end
def all_entries
- @all_entries ||= query
- .each_direct_result
- .map(&:itself)
- .filter { |r| r.fields["type"] == "TimeEntry" }
- .map { |r| TimeEntry.find(r.fields["id"]) }
+ @all_entries ||= begin
+ ids = query
+ .each_direct_result
+ .filter { |r| r.fields["type"] == "TimeEntry" }
+ .flat_map { |r| r.fields["id"] }
+
+ TimeEntry.where(id: ids).includes(%i[user activity work_package project])
+ end
end
def build_table_rows(entries)