<commit_before>import template from './watcher_edit_every_schedule.html';

class WatcherEditEverySchedule {
  constructor() {
    this.enabled = true;
    this.selected = 'minutes';
    this.number = 1;
    this.options = ['seconds', 'minutes', 'hours', 'days', 'months', 'years'];
  }

  handleChange() {
    this.watcher._source.trigger.schedule.later = `every ${this.number} ${this.selected}`;
  }
}

function watcherEditEverySchedule() {
  return {
    template,
    restrict: 'E',
    scope: {
      watcher: '=',
    },
    controller:  WatcherEditEverySchedule,
    controllerAs: 'watcherEditEverySchedule',
    bindToController: true,
  };
}

export default watcherEditEverySchedule;<commit_msg>Correctly read schedule if every.<commit_after>import template from './watcher_edit_every_schedule.html';

class WatcherEditEverySchedule {
  constructor() {
    this.enabled = true;
    this.selected = 'minutes';
    this.options = ['seconds', 'minutes', 'hours', 'days', 'months', 'years'];
  }

  $onInit() {
    this.number = this._getNumber();
  }

  _getNumber() {
    const number = /every\s(\d+)\s\w+/.exec(this.watcher._source.trigger.schedule.later);
    if (!number) return 1;
    return +number[1];
  }

  handleSelected() {
    this.watcher._source.trigger.schedule.later = `every ${this.number} ${this.selected}`;
  }
}

function watcherEditEverySchedule() {
  return {
    template,
    restrict: 'E',
    scope: {
      watcher: '=',
    },
    controller:  WatcherEditEverySchedule,
    controllerAs: 'watcherEditEverySchedule',
    bindToController: true,
  };
}

export default watcherEditEverySchedule;
{'fraction_non_alphanumeric': 0.14707692307692308, 'fraction_numerical': 0.0018461538461538461, 'mean_word_length': 3.7130434782608694, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3640145', 'n_tokens_mistral': 529, 'n_tokens_neox': 511, 'n_words': 98}