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
fix loading only at single historical timestamp
ulferts9e534b157633
diff --git a/app/models/journable/with_historic_attributes.rb b/app/models/journable/with_historic_attributes.rbindex 728861e71e1..1ba4cb59c20 100644--- a/app/models/journable/with_historic_attributes.rb+++ b/app/models/journable/with_historic_attributes.rb@@ -138,7 +138,11 @@ class Journable::WithHistoricAttributes < SimpleDelegatorenddef matches_query_filters_at_timestamps- timestamps.select { |timestamp| loader.work_package_ids_of_query_at_timestamp(query:, timestamp:).include?(__getobj__.id) }+ if query.present?+ timestamps.select { |timestamp| loader.work_package_ids_of_query_at_timestamp(query:, timestamp:).include?(__getobj__.id) }+ else+ []+ endenddef exists_at_timestamps@@ -154,7 +158,7 @@ class Journable::WithHistoricAttributes < SimpleDelegatorenddef matches_query_filters_at_baseline_timestamp?- query && matches_query_filters_at_timestamps.include?(baseline_timestamp)+ matches_query_filters_at_timestamps.include?(baseline_timestamp)enddef current_timestamp@@ -162,11 +166,11 @@ class Journable::WithHistoricAttributes < SimpleDelegatorenddef matches_query_filters_at_current_timestamp?- query && matches_query_filters_at_timestamps.include?(current_timestamp)+ matches_query_filters_at_timestamps.include?(current_timestamp)enddef matches_query_filters_at_timestamp?(timestamp)- query && matches_query_filters_at_timestamps.include?(timestamp)+ matches_query_filters_at_timestamps.include?(timestamp)enddef at_timestamp(timestamp)diff --git a/lib/api/v3/work_packages/eager_loading/base.rb b/lib/api/v3/work_packages/eager_loading/base.rbindex bd1a107d1ff..f5cc8486091 100644--- a/lib/api/v3/work_packages/eager_loading/base.rb+++ b/lib/api/v3/work_packages/eager_loading/base.rb@@ -30,7 +30,7 @@ module APImodule V3module WorkPackagesmodule EagerLoading- class Base < SimpleDelegator+ class Basedef initialize(work_packages)self.work_packages = work_packagesenddiff --git a/lib/api/v3/work_packages/eager_loading/historic_attributes.rb b/lib/api/v3/work_packages/eager_loading/historic_attributes.rbindex f02ce94cb5d..0ddf182ad04 100644--- a/lib/api/v3/work_packages/eager_loading/historic_attributes.rb+++ b/lib/api/v3/work_packages/eager_loading/historic_attributes.rb@@ -36,9 +36,10 @@ module API::V3::WorkPackages::EagerLoadingwork_package_with_historic_attributes = work_packages_with_historic_attributes[work_package.id]- set_non_delegated_properties(work_package,- work_package_with_historic_attributes,- work_package_with_historic_attributes.timestamps.last.to_s)+ set_attributes_at_timestamp(work_package,+ work_package_with_historic_attributes,+ work_package_with_historic_attributes.timestamps.last,+ override_current: true)work_package.at_timestamps = work_package_with_historic_attributes.timestamps@@ -46,9 +47,9 @@ module API::V3::WorkPackages::EagerLoadingwrapped_wp = AttributesByTimestampWorkPackage.new(work_package_with_historic_attributes.at_timestamp(timestamp), timestamp)- set_non_delegated_properties(wrapped_wp,- work_package_with_historic_attributes,- wrapped_wp.timestamp)+ set_attributes_at_timestamp(wrapped_wp,+ work_package_with_historic_attributes,+ wrapped_wp.timestamp)wrapped_wpend@@ -60,7 +61,8 @@ module API::V3::WorkPackages::EagerLoadingprivate- def set_non_delegated_properties(work_package, source, timestamp)+ def set_attributes_at_timestamp(work_package, source, timestamp, override_current: false)+ work_package.attributes = source.attributes.except('timestamp') if override_currentwork_package.matches_filters_at_timestamp = source.matches_query_filters_at_timestamps.include?(timestamp)work_package.exists_at_timestamp = source.exists_at_timestamps.include?(timestamp)work_package.attributes_changed_to_baseline = source.changed_at_timestamp(timestamp)diff --git a/lib/api/v3/work_packages/work_package_eager_loading_wrapper.rb b/lib/api/v3/work_packages/work_package_eager_loading_wrapper.rbindex d5cbb52059e..6673b7e7aae 100644--- a/lib/api/v3/work_packages/work_package_eager_loading_wrapper.rb+++ b/lib/api/v3/work_packages/work_package_eager_loading_wrapper.rb@@ -75,13 +75,13 @@ module APIdef eager_loader_classes_all[+ ::API::V3::WorkPackages::EagerLoading::HistoricAttributes,::API::V3::WorkPackages::EagerLoading::Hierarchy,::API::V3::WorkPackages::EagerLoading::Ancestor,::API::V3::WorkPackages::EagerLoading::Project,::API::V3::WorkPackages::EagerLoading::Checksum,::API::V3::WorkPackages::EagerLoading::CustomValue,- ::API::V3::WorkPackages::EagerLoading::CustomAction,- ::API::V3::WorkPackages::EagerLoading::HistoricAttributes+ ::API::V3::WorkPackages::EagerLoading::CustomAction]enddiff --git a/spec/requests/api/v3/work_packages/index_resource_spec.rb b/spec/requests/api/v3/work_packages/index_resource_spec.rbindex 75757bee9c0..1fdcee22e0f 100644--- a/spec/requests/api/v3/work_packages/index_resource_spec.rb+++ b/spec/requests/api/v3/work_packages/index_resource_spec.rb@@ -33,6 +33,8 @@ describe 'API v3 Work package resource',content_type: :json doinclude API::V3::Utilities::PathHelper+ create_shared_association_defaults_for_work_package_factory+let(:work_package) docreate(:work_package,project_id: project.id,