<commit_before>'use strict';

var _ = require('lodash');

function init() {

  function simplealarms() {
    return simplealarms;
  }

  simplealarms.label = 'Simple Alarms';
  simplealarms.pluginType = 'notification';

  simplealarms.checkNotifications = function checkNotifications(sbx) {
    var lastSGV = sbx.scaleBg(sbx.data.lastSGV())
      , lastSGVEntry = _.last(sbx.data.sgvs)
      , trigger = false
      , level = 0
      , title = ''
      , pushoverSound = null
      ;

    if (lastSGV) {
      if (lastSGV > sbx.scaleBg(sbx.thresholds.bg_high)) {
        trigger = true;
        level = 2;
        title = 'Urgent HIGH';
        pushoverSound = 'persistent';
        console.info(title + ': ' + (lastSGV + ' > ' + sbx.scaleBg(sbx.thresholds.bg_high)));
      } else if (lastSGV > sbx.thresholds.bg_target_top) {
        trigger = true;
        level = 1;
        title = 'High warning';
        pushoverSound = 'climb';
        console.info(title + ': ' + (lastSGV + ' > ' + sbx.scaleBg(sbx.thresholds.bg_target_top)));
      } else if (lastSGV < sbx.thresholds.bg_low) {
        trigger = true;
        level = 2;
        title = 'Urgent LOW';
        pushoverSound = 'persistent';
        console.info(title + ': ' + (lastSGV + ' < ' + sbx.scaleBg(sbx.thresholds.bg_low)));
      } else if (lastSGV < sbx.thresholds.bg_target_bottom) {
        trigger = true;
        level = 1;
        title = 'Low warning';
        pushoverSound = 'falling';
        console.info(title + ': ' + (lastSGV + ' < ' + sbx.scaleBg(sbx.thresholds.bg_target_bottom)));
      } else if (sbx.thresholds.bg_magic && lastSVG == sbx.thresholds.bg_magic && lastSGVEntry.direction == 'Flat') {
        trigger = true;
        level = o;
        title = 'Perfect';
        pushoverSound = 'magic';
      }



      if (trigger) {
        sbx.notifications.requestNotify({
          level: level
          , title: title
          , message: [lastSGV, sbx.unitsLabel].join(' ')
          , pushoverSound: pushoverSound<commit_msg>Had missed a couple thresholds in Simple Alarms. (Need to configure test env to use the same profile as production)<commit_after>'use strict';

var _ = require('lodash');

function init() {

  function simplealarms() {
    return simplealarms;
  }

  simplealarms.label = 'Simple Alarms';
  simplealarms.pluginType = 'notification';

  simplealarms.checkNotifications = function checkNotifications(sbx) {
    var lastSGV = sbx.scaleBg(sbx.data.lastSGV())
      , lastSGVEntry = _.last(sbx.data.sgvs)
      , trigger = false
      , level = 0
      , title = ''
      , pushoverSound = null
      ;

    if (lastSGV) {
      if (lastSGV > sbx.scaleBg(sbx.thresholds.bg_high)) {
        trigger = true;
        level = 2;
        title = 'Urgent HIGH';
        pushoverSound = 'persistent';
        console.info(title + ': ' + (lastSGV + ' > ' + sbx.scaleBg(sbx.thresholds.bg_high)));
      } else if (lastSGV > sbx.scaleBg(sbx.thresholds.bg_target_top)) {
        trigger = true;
        level = 1;
        title = 'High warning';
        pushoverSound = 'climb';
        console.info(title + ': ' + (lastSGV + ' > ' + sbx.scaleBg(sbx.thresholds.bg_target_top)));
      } else if (lastSGV < sbx.scaleBg(sbx.thresholds.bg_low)) {
        trigger = true;
        level = 2;
        title = 'Urgent LOW';
        pushoverSound = 'persistent';
        console.info(title + ': ' + (lastSGV + ' < ' + sbx.scaleBg(sbx.thresholds.bg_low)));
      } else if (lastSGV < sbx.scaleBg(sbx.thresholds.bg_target_bottom)) {
        trigger = true;
        level = 1;
        title = 'Low warning';
        pushoverSound = 'falling';
        console.info(title + ': ' + (lastSGV + ' < ' + sbx.scaleBg(sbx.thresholds.bg_target_bottom)));
      } else if (sbx.thresholds.bg_magic && lastSVG == sbx.thresholds.bg_magic && lastSGVEntry.direction == 'Flat') {
        trigger = true;
        level = o;
        title = 'Perfect';
        pushoverSound = 'magic';
      }



      if (trigger) {
        sbx.notifications.requestNotify({
          level: level
          , title: title
          , message: [lastSGV, sbx.unitsLabel].join(' ')
          , pushoverSound: pushoverSound
{'fraction_non_alphanumeric': 0.13741920038305003, 'fraction_numerical': 0.0023940627244433805, 'mean_word_length': 2.331738437001595, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '7191752', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1366, 'n_words': 262}