lib/khronos/server/scheduler.rb in khronos-0.0.3.pre2 vs lib/khronos/server/scheduler.rb in khronos-0.0.3.pre3

- old
+ new

@@ -80,11 +80,20 @@ schedule = Storage::Schedule.where({:id => params.delete('id')}).first # No schedule found for this params. return {}.to_json unless schedule - schedule.update_attributes(params) + if params['patch'] + # When recurrency check requested + if schedule.recurrency > 0 + schedule.at += schedule.recurrency + schedule.active = true + end + else + # When put requested + schedule.update_attributes(params) + end schedule.save schedule.to_json end @@ -92,22 +101,9 @@ # # @param [String] id # # @return [Hash] data patch '/task' do - schedule = Storage::Schedule.where(params).first - - # No schedule found for this params. - return {}.to_json unless schedule - - # Is recurrency check requested - if schedule.recurrency > 0 - schedule.at += schedule.recurrency - schedule.active = true - end - schedule.save - - schedule.to_json end # Force a task to be scheduled right now # # @param [Integer] id