jmettraux / ruote

a ruby workflow engine (dead)
MIT License
496 stars 74 forks source link

Time-setting / parsing failure #73

Closed coffeeaddict closed 11 years ago

coffeeaddict commented 11 years ago

I am not particular sure where to file this one, so I will just file it here, in the ruote 'core'.

I have a Rails application with Ruote and a ruote-mon storage. In my process, a reminder is sent x-days after some participant in the flow has done her job.

The short version of the pdef looks something like:

define workflow
   my_participant
   sequence
     wait until: '${f:reminder}'
     send_mail mail: 'reminder_mail'

and my first-stab-at-a participant looked like:

class MyParticipant < Ruote::Participant
  def on_workitem
    # ...
    workitem.fields['reminder'] = 20.days.from_now
  end
end

This fails because I use ruote-mon. BSON does not play nice with the ActiveSupport::TimeWithZone, and only accepts 20.days.from_now.utc. That is fine by me, I do not expect the storage layer of ruote to handle with such detail.

When using the time as .utc, the final string in the reminder field turns into: '2013-02-08T17:36:10Z' - which raises

ArgumentError: cannot parse '2013-02-08T17:36:10Z'
  from /.../ruby/1.9.1/gems/rufus-scheduler-2.0.17/lib/rufus/sc/rtime.rb:139:in `parse_time_string'
  from /.../ruby/1.9.1/gems/ruote-2.3.0.2/lib/ruote/util/time.rb:78:in `s_to_at'
  from /.../ruby/1.9.1/gems/ruote-2.3.0.2/lib/ruote/storage/base.rb:343:in `prepare_schedule_doc'
  from /.../ruby/1.9.1/gems/ruote-2.3.0.2/lib/ruote/storage/base.rb:198:in `put_schedule'
  ... etc. etc ...

(tell me if you need more)

I believe that this notation is a viable, parsable string representation of a time that ruote (or rufus) should parse

As a work-around I am now using strftime;

    workitem.fields['reminder'] = 20.days.from_now.strftime("%F %T")
jmettraux commented 11 years ago

Many thanks!

coffeeaddict commented 11 years ago

:+1: for the quick fix