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

Fix timestamps allowing all oneDayAgo timestamps (#12855)

Oliver Günther72c958bee67d
diff --git a/app/models/query.rb b/app/models/query.rb
index 5a5b29eebae..8c20401bc18 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -438,8 +438,7 @@ class Query < ApplicationRecord
def allowed_timestamps
return timestamps if EnterpriseToken.allows_to?(:baseline_comparison)
-
- timestamps.reject { |t| t.to_time < Date.yesterday }
+ timestamps.select { |t| t.one_day_ago? || t.to_time >= Date.yesterday }
end
def valid_filter_subset!
diff --git a/app/models/timestamp.rb b/app/models/timestamp.rb
index 12d0e03c494..dd5f57ac388 100644
--- a/app/models/timestamp.rb
+++ b/app/models/timestamp.rb
@@ -128,6 +128,10 @@ class Timestamp
to_s.match? TimestampParser::DATE_KEYWORD_REGEX
end
+ def one_day_ago?
+ to_s.start_with? 'oneDayAgo'
+ end
+
def to_s
@timestamp_string.to_s
end
diff --git a/spec/models/query_spec.rb b/spec/models/query_spec.rb
index 9b908f293b1..6afc1b38d25 100644
--- a/spec/models/query_spec.rb
+++ b/spec/models/query_spec.rb
@@ -146,6 +146,12 @@ RSpec.describe Query,
it { is_expected.to be_valid }
end
+ context "when the 'oneDayAgo' with a timezone is provided" do
+ let(:timestamps) { ["oneDayAgo@00:00+09:00"] }
+
+ it { is_expected.to be_valid }
+ end
+
context "when the shortcut value 'now' is provided" do
let(:timestamps) { ["now"] }