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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Query::Timestamps: implement switch to only use historic queries when historic timestamps are given
Sebastian Fiedlschusterf551359a14f4
diff --git a/app/models/query/results.rb b/app/models/query/results.rbindex e932b10740f..560468ecf54 100644--- a/app/models/query/results.rb+++ b/app/models/query/results.rb@@ -44,19 +44,31 @@ class ::Query::Results# Returns the work packages adhering to the filters and ordered by the provided criteria (grouping and sorting)def work_packages+ if query.historic?+ sorted_work_packages_matching_the_filters_at_any_of_the_given_timestamps+ else+ sorted_work_packages_matching_the_filters_today+ end+ end++ def sorted_work_packages_matching_the_filters_todaywork_package_scope- .where(id: work_package_ids)+ .where(query.statement).includes(all_includes)- .joins(sort_criteria_joins)+ .joins(all_joins).order(order_option).references(:projects).order(sort_criteria_array)end- def work_package_ids- # For filtering on historic data, we need to collect the work package ids- # matching the filters for all search timestamps provided in the query.- work_package_ids_for_all_timestamps+ def sorted_work_packages_matching_the_filters_at_any_of_the_given_timestamps+ work_package_scope+ .where(id: work_packages_matching_the_filters_at_any_of_the_given_timestamps)+ .includes(all_includes)+ .joins(sort_criteria_joins)+ .order(order_option)+ .references(:projects)+ .order(sort_criteria_array)enddef order_option@@ -71,10 +83,10 @@ class ::Query::Resultsprivate- # For filtering on historic data, this returns the work package ids- # matching the filters for all search timestamps provided in the query.+ # For filtering on historic data, this returns the work packages+ # matching the filters for any of the timestamps provided in the query.#- def work_package_ids_for_all_timestamps+ def work_packages_matching_the_filters_at_any_of_the_given_timestampsquery.timestamps.collect do |timestamp|WorkPackage.where(id: work_packages_relation.at_timestamp(timestamp))end.reduce(:or)diff --git a/app/models/query/timestamps.rb b/app/models/query/timestamps.rbindex 3c667479b14..e1e6cf7f64a 100644--- a/app/models/query/timestamps.rb+++ b/app/models/query/timestamps.rb@@ -51,5 +51,11 @@ module Query::Timestampsdef timestamps=(array)super(array.collect { |element| element.respond_to?(:iso8601) ? element.iso8601 : element })end++ # Does this query perform a historic search?+ #+ def historic?+ timestamps != [Timestamp.now]+ endendend