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
[#65866] NoMethodError in GET::API::V3::Queries::QueriesAPI#/queries/:id/
Dombi Attila38488e2993d4
diff --git a/app/models/journal/timestamps.rb b/app/models/journal/timestamps.rbindex ca0d55d4835..0e3aa93ccb0 100644--- a/app/models/journal/timestamps.rb+++ b/app/models/journal/timestamps.rb@@ -72,6 +72,12 @@ module Journal::Timestampstimestamp = timestamp.to_time if timestamp.kind_of? Timestamptimestamp = timestamp.in_time_zone if timestamp.kind_of? DateTime+ # By default rails will chop off the timezone from a date time parameter and just let+ # postgresql to use the db session's timezone, which can be different from UTC.+ # Pass the timestamp as a string including the UTC timezone explicitly, to the query+ # in order to force postgres to use UTC instead of the session's timezone.++ timestamp = timestamp.utc.to_swhere(OpenProject::SqlSanitization.sanitize("validity_period @> timestamp with time zone :timestamp", timestamp:))endenddiff --git a/spec/models/journal/timestamps_spec.rb b/spec/models/journal/timestamps_spec.rbindex a2bf4bd43f9..42be6f4022a 100644--- a/spec/models/journal/timestamps_spec.rb+++ b/spec/models/journal/timestamps_spec.rb@@ -94,6 +94,17 @@ RSpec.describe Journal::Timestamps doendend+ describe "when ensuring UTC is passed to the timestamp where condition" do+ it "converts the timestamp to UTC in the generated SQL" do+ sql = Time.use_zone("America/New_York") do+ est_time = Time.zone.parse("2022-08-01 11:30:00")+ Journal.at_timestamp(est_time).to_sql+ end+ expect(sql)+ .to include(/validity_period @> timestamp with time zone '2022-08-01 15:30:00 UTC'/)+ end+ end+describe "when there are journals for Monday, Wednesday, and Friday" dolet(:before_monday) { "2022-01-01".to_datetime }let(:monday) { "2022-08-01".to_datetime }