Uploaded image for project: 'Modules'
  1. Modules
  2. MODULES-7291

scheduled_task: Refactor trigger definitions / validation logic in canonicalize_and_validate

    XMLWordPrintable

Details

    • Task
    • Status: Open
    • Normal
    • Resolution: Unresolved
    • None
    • None
    • scheduled_task
    • Needs Assessment

    Description

      Logic in the canonicalize_and_validate method takes a number of unique code paths specific to individual trigger types. It may be more useful to define some Ruby hashes that contain a "schema", so that validation logic could be more normalized / handled generically.

      So for instance, something like

      # base ITrigger
      trigger_defaults => {
        fields => {
          'schedule' => { type => String, values => 'daily, weekly, monthly, once', required => true },
          'start_time' => { type => String, pattern => '\d\d:\d\d', required => true },
          'start_date' => { type => String },
          'minutes_interval' => { type => Integer },
          'minutes_duration' => { type => Integer },
        }
      }
      daily_trigger => {
        type => 2,
        fields => {
          'every' => { type => Numeric, values => [1, 2] },
          # etc
        }
      }
      monthly_trigger => {
        type => 4,
        fields => {
          'which_occurrence' => { type => Array, values => ['first', 'second', 'third', 'fourth', 'last'] }
          # etc
        }
      }
      

      I won't model them all out, but that should set the gist of things.

      A full breakdown of all allowed values is in
      https://gist.github.com/Iristyle/58ff446bd3f60e68d52df3868c917a0e

      This is also likely the best way to fix the bug where mutually exclusive trigger hash settings are currently ignored. For example, a schedule of 'once' will accept an every value of '1', even though its unused, and there a number of other such examples.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ethan Ethan Brown
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Zendesk Support