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
Load the custom_values association only on the Journable::WithHistoricAttributes
Dombi Attila57c3bf093da0
diff --git a/app/models/journable/with_historic_attributes/loader.rb b/app/models/journable/with_historic_attributes/loader.rbindex 385dfb350ec..dc51eeeb39c 100644--- a/app/models/journable/with_historic_attributes/loader.rb+++ b/app/models/journable/with_historic_attributes/loader.rb@@ -70,11 +70,11 @@ class Journable::WithHistoricAttributes'ie: WorkPackage.at_timestamp(1.day.ago) or WorkPackage.find(1).at_timestamp(1.day.ago)'end- journals_by_id = load_journals_by_id(journal_ids)+ customizable_journals_by_journal_id = load_customizable_journals_by_journal_id(journal_ids)journalized.each do |work_package|- journal = journals_by_id[work_package.journal_id]- set_custom_value_association_from_journal!(work_package:, journal:)+ customizable_journals = Array(customizable_journals_by_journal_id[work_package.journal_id])+ set_custom_value_association_from_journal!(work_package:, customizable_journals:)endjournalizedend@@ -116,21 +116,18 @@ class Journable::WithHistoricAttributesjournables.first.classend- def load_journals_by_id(journal_ids)- Journal- .where(id: journal_ids)- .includes({ customizable_journals: :custom_field })- .index_by(&:id)+ def load_customizable_journals_by_journal_id(journal_ids)+ Journal::CustomizableJournal+ .where(journal_id: journal_ids)+ .includes(:custom_field)+ .index_by(&:journal_id)end- def set_custom_value_association_from_journal!(work_package:, journal:)- work_package.association(:journals).loaded!- work_package.association(:journals).target = Array(journal)-+ def set_custom_value_association_from_journal!(work_package:, customizable_journals:)# Build the associated customizable_journals as custom values, this way the historic work packages# will behave just as the normal ones. Additionally set the reverse customized association# on the custom_values that points to the work_package itself.- historic_custom_values = Array(journal&.customizable_journals).map do |customizable_journal|+ historic_custom_values = customizable_journals.map do |customizable_journal|customizable_journal.as_custom_value(customized: work_package)end