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
Refactor time_entry_hours.rb to reduce ABC size
Mir Bhatia0f80668db99f
diff --git a/lib/open_project/journal_formatter/time_entry_hours.rb b/lib/open_project/journal_formatter/time_entry_hours.rbindex c70333961c2..0739185748b 100644--- a/lib/open_project/journal_formatter/time_entry_hours.rb+++ b/lib/open_project/journal_formatter/time_entry_hours.rb@@ -32,20 +32,7 @@ class OpenProject::JournalFormatter::TimeEntryHours < JournalFormatter::Baselabel_text << ':' if !values.firstlabel_text = content_tag(:strong, label_text) if options[:html]- html = options[:html] ? '_html' : ''-- first = format_float(values.first) if values.first- last = format_float(values.last)-- value =- if first- I18n.t(:'activity.item.time_entry.updated',- first: I18n.t(:"activity.item.time_entry.hour#{html}", count: first),- last: I18n.t(:"activity.item.time_entry.hour#{html}", count: last))- else- I18n.t(:"activity.item.time_entry.hour#{html}",- count: last)- end+ value = value(options[:html], values.first, values.last)I18n.t(:text_journal_of, label: label_text, value:)end@@ -55,4 +42,20 @@ class OpenProject::JournalFormatter::TimeEntryHours < JournalFormatter::Basedef format_float(val)(val % 1).zero? ? val.to_i : valend++ def value(html, first, last)+ html = html ? '_html' : ''++ first = format_float(first) if first+ last = format_float(last)++ if first+ I18n.t(:'activity.item.time_entry.updated',+ first: I18n.t(:"activity.item.time_entry.hour#{html}", count: first),+ last: I18n.t(:"activity.item.time_entry.hour#{html}", count: last))+ else+ I18n.t(:"activity.item.time_entry.hour#{html}",+ count: last)+ end+ endend