lib/luxafor/toggl/client.rb in luxafor-toggl-1.0.2 vs lib/luxafor/toggl/client.rb in luxafor-toggl-1.0.3
- old
+ new
@@ -20,11 +20,11 @@
private
attr_reader :toggl, :luxafor, :state_file
def latest_task
- start = DateTime.now - 1
- @_latest_task = toggl.get_time_entries(start_date: start).last
+ start = DateTime.now - 1
+ @_latest_task ||= toggl.get_time_entries(start_date: start).max_by { |task| Time.parse(task["start"]) }
end
def current_state
@_current_state ||= State.new_from_task(latest_task)
end