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

baseline api: fix naming of `matches_query_filters_at_timestamp`

Sebastian Fiedlschuster32d92a04a2ae
diff --git a/app/models/journable/with_historic_attributes.rb b/app/models/journable/with_historic_attributes.rb
index 1b8244f3436..c4c471c9ad3 100644
--- a/app/models/journable/with_historic_attributes.rb
+++ b/app/models/journable/with_historic_attributes.rb
@@ -64,8 +64,8 @@
# work_package = Journable::WithHistoricAttributes.wrap(work_package, query:)
# work_package.baseline_timestamp # => [<Timestamp 2022-01-01T00:00:00Z>]
# work_package.current_timestamp # => [<Timestamp PT0S>]
-# work_package.matches_query_filter_at_baseline_timestamp?
-# work_package.matches_query_filter_at_current_timestamp?
+# work_package.matches_query_filters_at_baseline_timestamp?
+# work_package.matches_query_filters_at_current_timestamp?
# work_package.baseline_attributes.subject # => "Subject at 2022-01-01 (baseline time)"
# work_package.subject # => "Subject at PT0S (current time)"
#
@@ -187,7 +187,7 @@ class Journable::WithHistoricAttributes < SimpleDelegator
attributes_by_timestamp[baseline_timestamp.to_s]
end
- def matches_query_filter_at_baseline_timestamp?
+ def matches_query_filters_at_baseline_timestamp?
query && matches_query_filters_at_timestamps.include?(baseline_timestamp)
end
@@ -195,11 +195,11 @@ class Journable::WithHistoricAttributes < SimpleDelegator
timestamps.last
end
- def matches_query_filter_at_current_timestamp?
+ def matches_query_filters_at_current_timestamp?
query && matches_query_filters_at_timestamps.include?(current_timestamp)
end
- def matches_query_filter_at_timestamp?(timestamp)
+ def matches_query_filters_at_timestamp?(timestamp)
query && matches_query_filters_at_timestamps.include?(timestamp)
end
diff --git a/lib/api/v3/work_packages/eager_loading/historic_attributes.rb b/lib/api/v3/work_packages/eager_loading/historic_attributes.rb
index a350b1f0688..e7014adf9aa 100644
--- a/lib/api/v3/work_packages/eager_loading/historic_attributes.rb
+++ b/lib/api/v3/work_packages/eager_loading/historic_attributes.rb
@@ -37,8 +37,8 @@ module API::V3::WorkPackages::EagerLoading
work_package.baseline_attributes = work_package_with_historic_attributes.baseline_attributes
work_package.attributes_by_timestamp = work_package_with_historic_attributes.attributes_by_timestamp
work_package.baseline_timestamp = work_package_with_historic_attributes.baseline_timestamp
- work_package.matches_query_filter_at_baseline_timestamp = \
- work_package_with_historic_attributes.matches_query_filter_at_baseline_timestamp?
+ work_package.matches_query_filters_at_baseline_timestamp = \
+ work_package_with_historic_attributes.matches_query_filters_at_baseline_timestamp?
work_package.matches_query_filters_at_timestamps = work_package_with_historic_attributes.matches_query_filters_at_timestamps
end
@@ -62,21 +62,21 @@ module API::V3::WorkPackages::EagerLoading
included do
attr_accessor :baseline_attributes, :attributes_by_timestamp, :baseline_timestamp,
- :matches_query_filter_at_baseline_timestamp,
+ :matches_query_filters_at_baseline_timestamp,
:matches_query_filters_at_timestamps
end
# 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_filters_at_timestamps.any? ? matches_query_filter_at_baseline_timestamp : nil
+ def matches_query_filters_at_baseline_timestamp?
+ matches_query_filters_at_timestamps.any? ? matches_query_filters_at_baseline_timestamp : nil
end
# 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)
+ def matches_query_filters_at_timestamp?(timestamp)
matches_query_filters_at_timestamps.any? ? matches_query_filters_at_timestamps.include?(timestamp) : nil
end
end
diff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rb
index ff378688693..8a76da14cd0 100644
--- a/lib/api/v3/work_packages/work_package_representer.rb
+++ b/lib/api/v3/work_packages/work_package_representer.rb
@@ -459,7 +459,7 @@ module API
},
'_meta': {
'timestamp': baseline_timestamp.to_s,
- 'matchesFilters': matches_query_filter_at_baseline_timestamp?
+ 'matchesFilters': matches_query_filters_at_baseline_timestamp?
}.compact
})
end,
@@ -478,7 +478,7 @@ module API
}
},
'_meta': {
- 'matchesFilters': matches_query_filter_at_timestamp?(timestamp)
+ 'matchesFilters': matches_query_filters_at_timestamp?(timestamp)
}.compact
})]
end.to_h
diff --git a/spec/models/journable/with_historic_attributes_spec.rb b/spec/models/journable/with_historic_attributes_spec.rb
index f815c4997c5..d4b6d4f63ee 100644
--- a/spec/models/journable/with_historic_attributes_spec.rb
+++ b/spec/models/journable/with_historic_attributes_spec.rb
@@ -246,7 +246,7 @@ describe Journable::WithHistoricAttributes do
end
end
- describe "#matches_query_filter_at_baseline_timestamp?" do
+ describe "#matches_query_filters_at_baseline_timestamp?" do
let(:timestamps) { [Timestamp.parse("2022-01-01T00:00:00Z"), Timestamp.parse("PT0S")] }
let(:journable) { described_class.wrap(work_package, timestamps:, query:) }
let(:query) do
@@ -257,7 +257,7 @@ describe Journable::WithHistoricAttributes do
end
end
- subject { journable.matches_query_filter_at_baseline_timestamp? }
+ subject { journable.matches_query_filters_at_baseline_timestamp? }
describe "providing a filter that matches at the baseline timestamp" do
let(:search_term) { "original" }
@@ -287,7 +287,7 @@ describe Journable::WithHistoricAttributes do
end
end
- describe "#matches_query_filter_at_current_timestamp?" do
+ describe "#matches_query_filters_at_current_timestamp?" do
let(:timestamps) { [Timestamp.parse("2022-01-01T00:00:00Z"), Timestamp.parse("PT0S")] }
let(:journable) { described_class.wrap(work_package, timestamps:, query:) }
let(:query) do
@@ -298,7 +298,7 @@ describe Journable::WithHistoricAttributes do
end
end
- subject { journable.matches_query_filter_at_current_timestamp? }
+ subject { journable.matches_query_filters_at_current_timestamp? }
describe "providing a filter that matches at the baseline timestamp" do
let(:search_term) { "original" }