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
baseline api: include `matchesFilters` meta info only if a query is given
Sebastian Fiedlschusterd172a4fc8051
diff --git a/app/models/journable/with_historic_attributes.rb b/app/models/journable/with_historic_attributes.rbindex 7a0cb6636e9..f8045a45452 100644--- a/app/models/journable/with_historic_attributes.rb+++ b/app/models/journable/with_historic_attributes.rb@@ -182,7 +182,7 @@ class Journable::WithHistoricAttributes < SimpleDelegatorenddef matches_query_filter_at_baseline_timestamp?- matches_query_at_timestamps.include?(baseline_timestamp)+ query && matches_query_at_timestamps.include?(baseline_timestamp)enddef current_timestamp@@ -190,11 +190,11 @@ class Journable::WithHistoricAttributes < SimpleDelegatorenddef matches_query_filter_at_current_timestamp?- matches_query_at_timestamps.include?(current_timestamp)+ query && matches_query_at_timestamps.include?(current_timestamp)enddef matches_query_filter_at_timestamp?(timestamp)- matches_query_at_timestamps.include?(timestamp)+ query && matches_query_at_timestamps.include?(timestamp)enddef self.query_work_packages(query:, timestamp: nil)diff --git a/lib/api/v3/work_packages/eager_loading/historic_attributes.rb b/lib/api/v3/work_packages/eager_loading/historic_attributes.rbindex d28846fffe1..c5390dd915c 100644--- a/lib/api/v3/work_packages/eager_loading/historic_attributes.rb+++ b/lib/api/v3/work_packages/eager_loading/historic_attributes.rb@@ -66,12 +66,18 @@ module API::V3::WorkPackages::EagerLoading:matches_query_at_timestampsend+ # Does the work package match the query filter at the baseline timestamp?+ # Returns `nil` if no query is given.+ #def matches_query_filter_at_baseline_timestamp?- matches_query_filter_at_baseline_timestamp+ matches_query_at_timestamps.any? ? matches_query_filter_at_baseline_timestamp : nilend+ # Does the work package match the query filter at the given timestamp?+ # Returns `nil` if no query is given.+ #def matches_query_filter_at_timestamp?(timestamp)- matches_query_at_timestamps.include?(timestamp)+ matches_query_at_timestamps.any? ? matches_query_at_timestamps.include?(timestamp) : nilendendenddiff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rbindex 5db849c6ec9..76cea344485 100644--- a/lib/api/v3/work_packages/work_package_representer.rb+++ b/lib/api/v3/work_packages/work_package_representer.rb@@ -460,7 +460,7 @@ module API"_meta": {"timestamp": baseline_timestamp.to_s,"matchesFilters": matches_query_filter_at_baseline_timestamp?- }+ }.compact})end,embedded: true,@@ -479,7 +479,7 @@ module API},"_meta": {"matchesFilters": matches_query_filter_at_timestamp?(timestamp)- }+ }.compact})]end.to_hend,diff --git a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_representer_spec.rbindex d74f6bb34be..89bce741742 100644--- a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb+++ b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb@@ -1366,6 +1366,12 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do.to be_json_eql(timestamps.first.to_s.to_json).at_path('_embedded/baselineAttributes/_meta/timestamp')end++ it 'has no information about whether the work package matches the query filters at the baseline time' \+ 'because there are no filters without a query' do+ expect(subject)+ .not_to have_json_path('_embedded/baselineAttributes/_meta/matchesFilters')+ endenddescribe 'attributesByTimestamp' do@@ -1390,6 +1396,14 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do.to be_json_eql(api_v3_paths.work_package(work_package.id, timestamps: [timestamps[1]]).to_json).at_path("_embedded/attributesByTimestamp/#{timestamps[1]}/_links/self/href")end++ it 'has no information about whether the work package matches the query filters at the timestamp' \+ 'because there are no filters without a query' do+ expect(subject)+ .not_to have_json_path("_embedded/attributesByTimestamp/#{timestamps[0]}/_meta/matchesFilters")+ expect(subject)+ .not_to have_json_path("_embedded/attributesByTimestamp/#{timestamps[1]}/_meta/matchesFilters")+ endendcontext 'when passing a query' do