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

Query::Timestamps: use sub queries rather than collecting ids

Sebastian Fiedlschuster4ba3c5aa24e6
diff --git a/app/models/query/results.rb b/app/models/query/results.rb
index 0c0f3212f77..e932b10740f 100644
--- a/app/models/query/results.rb
+++ b/app/models/query/results.rb
@@ -76,8 +76,8 @@ class ::Query::Results
#
def work_package_ids_for_all_timestamps
query.timestamps.collect do |timestamp|
- work_packages_relation.at_timestamp(timestamp).pluck(:id)
- end.flatten.uniq
+ WorkPackage.where(id: work_packages_relation.at_timestamp(timestamp))
+ end.reduce(:or)
end
# Returns an active-record relation that applies the filters to find the matching