def _add_weekly_rule(self, content):
     schedule = TimedSchedule.create_simple_weekly_schedule(
         self.domain,
         TimedEvent(time=time(12, 0)),
         content,
         [0, 4],
         0,
         total_iterations=3,
         repeat_every=2,
     )
     return self._add_rule(timed_schedule_id=schedule.schedule_id)
Ejemplo n.º 2
0
def migrate_simple_weekly_schedule(handler, migrator):
    if handler.schedule_length > 0 and (handler.schedule_length % 7) == 0:
        repeat_every = handler.schedule_length // 7
    elif handler.max_iteration_count == 1:
        repeat_every = 1
    else:
        raise ValueError("Unable to convert schedule_length for handler %s" % handler._id)

    return TimedSchedule.create_simple_weekly_schedule(
        handler.domain,
        get_timed_event(handler, handler.events[0]),
        get_content(handler, handler.events[0]),
        [handler.start_day_of_week],
        handler.start_day_of_week,
        total_iterations=handler.max_iteration_count,
        extra_options=get_extra_scheduling_options(handler, migrator, include_utc_option=True),
        repeat_every=repeat_every,
    )