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
at_timestamp: adding brief class documentation
Sebastian Fiedlschuster3ef95d869874
diff --git a/app/models/journable/historic_active_record_relation.rb b/app/models/journable/historic_active_record_relation.rbindex 8c43c24a6ac..f269c198ab9 100644--- a/app/models/journable/historic_active_record_relation.rb+++ b/app/models/journable/historic_active_record_relation.rb@@ -33,9 +33,22 @@# rubocop:disable Metrics/AbcSize# rubocop:disable Metrics/PerceivedComplexity+# In the context of the baseline-comparison feature, this class represents an active-record relation+# that queries historic data, i.e. performs its query e.g. on the `work_package_journals` table+# rather than the `work_packages` table.+#+# Usage:+#+# timestamp = 1.year.ago+# active_record_relation = WorkPackage.where(subject: "Foo")+# historic_relation = Journable::HistoricActiveRecordRelation.new(active_record_relation, timestamp:)+#+# See also:+#+# - https://github.com/opf/openproject/pull/11243+# - https://community.openproject.org/projects/openproject/work_packages/26448+#class Journable::HistoricActiveRecordRelation < ActiveRecord::Relation- # See: https://github.com/opf/openproject/pull/11243-attr_accessor :timestampinclude ActiveRecord::Delegation::ClassSpecificRelationdiff --git a/app/models/journable/timestamps.rb b/app/models/journable/timestamps.rbindex 2ed3e7f0b6c..4797208e64e 100644--- a/app/models/journable/timestamps.rb+++ b/app/models/journable/timestamps.rb@@ -26,9 +26,27 @@# See COPYRIGHT and LICENSE files for more details.#+++# In the context of the baseline-comparison feature, this module adds convenience methods+# to the `Journable` class in order to easy access to historic queries.+#+# Usage:+#+# # Retrieve historic state of single work package+# work_package = WorkPackage.find(1)+# historic_work_package = work_package.at_timestamp(1.year.ago)+# historic_work_package.id # => 1 (same as work_package.id)+# historic_work_package.historic? # => true+# historic_work_package.save # raises `ActiveRecord::ReadOnlyRecord`#+#+# # Filter on historic data+# WorkPackage.at_timestamp(1.year.ago).where(assigned_to_id: 1)+#+# See also:+#+# - https://github.com/opf/openproject/pull/11243+# - https://community.openproject.org/projects/openproject/work_packages/26448+#module Journable::Timestamps- # See: https://github.com/opf/openproject/pull/11243-extend ActiveSupport::Concernclass_methods dodiff --git a/app/models/journal/timestamps.rb b/app/models/journal/timestamps.rbindex 8defbc2d004..00f9c944d88 100644--- a/app/models/journal/timestamps.rb+++ b/app/models/journal/timestamps.rb@@ -30,9 +30,19 @@# Prefer `kind_of?` over `is_a?` because it reads well before vowel and consonant sounds.# E.g.: `relation.kind_of? ActiveRecord::Relation`+# In the context of the baseline-comparison feature, this module adds the `at_timestamp`+# scope to the `Journal` class.+#+# Usage:+#+# work_package.journals.at_timestamp(1.year.ago)+#+# See also:+#+# - https://github.com/opf/openproject/pull/11243+# - https://community.openproject.org/projects/openproject/work_packages/26448+#module Journal::Timestamps- # See: https://github.com/opf/openproject/pull/11243-extend ActiveSupport::Concernclass_methods do