lib/tomatoharvest/time_entry.rb
##
# Persist time entry to Harvest tracker
Persist time entry to Harvest tracker
Persist time entry to Harvest tracker
def log(seconds)
      hours = seconds_to_hours(seconds)
      return if hours == 0
      options = {
        notes: notes,
        hours: hours,
        spent_at: date,
        project_id: project.id,
        task_id: task.id
      }
      existing_entry = time_api.all.find do |entry|
        entry.notes == self.notes
      end
      if existing_entry
        existing_entry.hours += hours
        existing_entry.spent_at = date
        time_api.update(existing_entry)
      else
        entry = Harvest::TimeEntry.new(options)
        time_api.create(entry)
      end
    end
def log ( seconds ) hours = seconds_to_hours ( seconds ) return if hours == 0 options = { notes : notes , hours : hours , spent_at : date , project_id : project . id , task_id : task . id } existing_entry = time_api . all . find do | entry | entry . notes == self . notes end if existing_entry existing_entry . hours += hours existing_entry . spent_at = date time_api . update ( existing_entry ) else entry = Harvest :: TimeEntry . new ( options ) time_api . create ( entry ) end end
Persist time entry to Harvest tracker
Persist time entry to Harvest tracker
seconds