diff --git a/app/models/recipient_schedule.rb b/app/models/recipient_schedule.rb index 6e880cf3..3da952e1 100644 --- a/app/models/recipient_schedule.rb +++ b/app/models/recipient_schedule.rb @@ -146,7 +146,8 @@ class RecipientSchedule < ApplicationRecord def self.create_for_recipient(recipient_or_recipient_id, schedule, next_attempt_at=nil) if next_attempt_at.nil? - next_attempt_at = next_valid_attempt_time + next_attempt_at = Time.at(schedule.start_date.to_time.to_i + (60 * schedule.time)) + next_attempt_at += 1.day while next_attempt_at.on_weekend? end question_ids = schedule.question_list.question_ids.split(/,/) diff --git a/db/migrate/20170306145359_create_schedules.rb b/db/migrate/20170306145359_create_schedules.rb index afa6a5f7..337d339b 100644 --- a/db/migrate/20170306145359_create_schedules.rb +++ b/db/migrate/20170306145359_create_schedules.rb @@ -4,7 +4,7 @@ class CreateSchedules < ActiveRecord::Migration[5.0] t.references :school, foreign_key: true t.string :name t.text :description - t.integer :frequency_hours + t.integer :frequency_hours, default: 24 t.date :start_date t.date :end_date t.boolean :active, default: true diff --git a/db/schema.rb b/db/schema.rb index 92f50695..aaa5d361 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -122,7 +122,7 @@ ActiveRecord::Schema.define(version: 20170418173141) do t.integer "school_id" t.string "name" t.text "description" - t.integer "frequency_hours" + t.integer "frequency_hours", default: 24 t.date "start_date" t.date "end_date" t.boolean "active", default: true