Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule from hash missing validations #281

Closed
taylorbrooks opened this issue Feb 13, 2015 · 2 comments
Closed

Rule from hash missing validations #281

taylorbrooks opened this issue Feb 13, 2015 · 2 comments
Labels

Comments

@taylorbrooks
Copy link

I'm not sure what's going one here, but it doesn't seem like next_occurrences is obeying this recurring rule logic:

hash = {"validations"=>{"day"=>[]}, "rule_type"=>"IceCube::WeeklyRule", "interval"=>2, "until"=>nil, "count"=>nil}

So I turn the hash into an IceCube rule...

$ rule = IceCube::Rule.from_hash hash
=> #<IceCube::WeeklyRule:0x007fb4b5bb39f8
 @interval=2,
 @uses=0,
 @validations=
  {:interval=>[#<IceCube::Validations::WeeklyInterval::Validation:0x007fb4b5bb31b0 @interval=2, @week_start=:sunday>],
   :base_hour=>[#<IceCube::Validations::ScheduleLock::Validation:0x007fb4b5bb3750 @type=:hour>],
   :base_min=>[#<IceCube::Validations::ScheduleLock::Validation:0x007fb4b5bb36b0 @type=:min>],
   :base_sec=>[#<IceCube::Validations::ScheduleLock::Validation:0x007fb4b5bb3610 @type=:sec>]},
 @week_start=:sunday>

Then I create a schedule...

$ sched = IceCube::Schedule.new Date.today
=> #<IceCube::Schedule:0x007fb4b7214a80 @all_exception_rules=[], @all_recurrence_rules=[], @start_time=2015-02-13 00:00:00 -0600>

Add the rule

$ sched.add_recurrence_rule rule
=> [#<IceCube::WeeklyRule:0x007fb4b5bb39f8
  @interval=2,
  @uses=0,
  @validations=
   {:interval=>[#<IceCube::Validations::WeeklyInterval::Validation:0x007fb4b5bb31b0 @interval=2, @week_start=:sunday>],
    :base_hour=>[#<IceCube::Validations::ScheduleLock::Validation:0x007fb4b5bb3750 @type=:hour>],
    :base_min=>[#<IceCube::Validations::ScheduleLock::Validation:0x007fb4b5bb36b0 @type=:min>],
    :base_sec=>[#<IceCube::Validations::ScheduleLock::Validation:0x007fb4b5bb3610 @type=:sec>]},
  @week_start=:sunday>]

And inspect the next 20 occurrences

$ sched.next_occurrences 20
=> [Sat, 14 Feb 2015 00:00:00 UTC +00:00,
 Sun, 22 Feb 2015 00:00:00 UTC +00:00,
 Mon, 23 Feb 2015 00:00:00 UTC +00:00,
 Tue, 24 Feb 2015 00:00:00 UTC +00:00,
 Wed, 25 Feb 2015 00:00:00 UTC +00:00,
 Thu, 26 Feb 2015 00:00:00 UTC +00:00,
 Fri, 27 Feb 2015 00:00:00 UTC +00:00,
 Sat, 28 Feb 2015 00:00:00 UTC +00:00,
 Sun, 08 Mar 2015 00:00:00 UTC +00:00,
 Mon, 09 Mar 2015 00:00:00 UTC +00:00,
 Tue, 10 Mar 2015 00:00:00 UTC +00:00,
 Wed, 11 Mar 2015 00:00:00 UTC +00:00,
 Thu, 12 Mar 2015 00:00:00 UTC +00:00,
 Fri, 13 Mar 2015 00:00:00 UTC +00:00,
 Sat, 14 Mar 2015 00:00:00 UTC +00:00,
 Sun, 22 Mar 2015 00:00:00 UTC +00:00,
 Mon, 23 Mar 2015 00:00:00 UTC +00:00,
 Tue, 24 Mar 2015 00:00:00 UTC +00:00,
 Wed, 25 Mar 2015 00:00:00 UTC +00:00,
 Thu, 26 Mar 2015 00:00:00 UTC +00:00]

What am I missing here?

What does it show a week of consecutive days?

@avit
Copy link
Collaborator

avit commented Jan 31, 2016

Late reply, I know. Sorry, I'm just getting back to this project again.

That. Is. Weird. It looks like the rule from hash is missing a :base_wday validation. We should fix that.

@avit avit added the bug label Jan 31, 2016
@avit avit changed the title Next Occurrences not Obeying Schedule Rule from hash missing validations Jan 31, 2016
@taylorbrooks
Copy link
Author

@avit I haven't looked enough at the internals to know what's going on.

I'm happy to contribute in fixing this, but I don't even know where to start.

Can you maybe give me some direction?

avit added a commit to avit/ice_cube that referenced this issue Jan 18, 2017
@avit avit closed this as completed in #355 Jan 18, 2017
Chosko pushed a commit to Chosko/ice_cube that referenced this issue Mar 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants