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 rubocop issues in TimeEntryEvent

Klaus Zandersd32de5aed18e
diff --git a/modules/costs/lib/full_calendar/time_entry_event.rb b/modules/costs/lib/full_calendar/time_entry_event.rb
index 6d2be1f8fae..5d810d7a9df 100644
--- a/modules/costs/lib/full_calendar/time_entry_event.rb
+++ b/modules/costs/lib/full_calendar/time_entry_event.rb
@@ -34,13 +34,7 @@ module FullCalendar
class << self
def from_time_entry(time_entry)
- starts_at = time_entry.start_timestamp || time_entry.spent_on
- ends_at = time_entry.end_timestamp || time_entry.spent_on
-
- if time_entry.ongoing?
- starts_at = time_entry.created_at
- ends_at = Time.current
- end
+ starts_at, ends_at = start_and_end_time_from_time_entry(time_entry)
event = new(
id: time_entry.id,
@@ -53,6 +47,17 @@ module FullCalendar
event
end
+
+ def start_and_end_time_from_time_entry(time_entry)
+ if time_entry.ongoing?
+ [time_entry.created_at, Time.current]
+ else
+ [
+ time_entry.start_timestamp || time_entry.spent_on,
+ time_entry.end_timestamp || time_entry.spent_on
+ ]
+ end
+ end
end
def additional_attributes # rubocop:disable Metrics/AbcSize