<commit_before>'use strict';

var _ = require('lodash');
var levels = require('../levels');
var times = require('../times');
var simplealarms = require('./simplealarms')();

function init() {

  var treatmentnotify = {
    name: 'treatmentnotify'
    , label: 'Treatment Notifications'
    , pluginType: 'notification'
  };

  function filterTreatments (sbx) {
    var filterOpenAPS = sbx.extendedSettings.filter === 'openaps';
    var treatments = sbx.data.treatments;

    if (filterOpenAPS) {
      treatments = _.filter(treatments, function notOpenAPS (treatment) {
        return !treatment.enteredBy || treatment.enteredBy.indexOf('openaps://') === -1
      })
    }

    return treatments;
  }

  treatmentnotify.checkNotifications = function checkNotifications (sbx) {

    var treatments = filterTreatments(sbx);
    var lastMBG = sbx.lastEntry(sbx.data.mbgs);
    var lastTreatment = sbx.lastEntry(treatments);

    var mbgCurrent = isCurrent(lastMBG);
    var treatmentCurrent = isCurrent(lastTreatment);

    if (mbgCurrent || treatmentCurrent) {
      var mbgMessage = mbgCurrent ? 'Meter BG ' + sbx.scaleEntry(lastMBG) + ' ' + sbx.unitsLabel : '';
      var treatmentMessage = treatmentCurrent ? 'Treatment: ' + lastTreatment.eventType : '';<commit_msg>added list of OPENAPS_NONFILTERED event types, might need to exclude some more, but seems like a good start<commit_after>'use strict';

var _ = require('lodash');
var levels = require('../levels');
var times = require('../times');
var simplealarms = require('./simplealarms')();

var OPENAPS_NONFILTERED = ['Meal Bolus', 'Carb Correction', 'Correction Bolus'];

function init() {

  var treatmentnotify = {
    name: 'treatmentnotify'
    , label: 'Treatment Notifications'
    , pluginType: 'notification'
  };

  function filterTreatments (sbx) {
    var filterOpenAPS = sbx.extendedSettings.filter === 'openaps';
    var treatments = sbx.data.treatments;

    if (filterOpenAPS) {
      treatments = _.filter(treatments, function notOpenAPS (treatment) {
        var ok = true;
        if (treatment.enteredBy && treatment.enteredBy.indexOf('openaps://') === 0) {
          ok = _.indexOf(OPENAPS_NONFILTERED, treatment.eventType) >= 0;
        }
        return ok;
      })
    }

    return treatments;
  }

  treatmentnotify.checkNotifications = function checkNotifications (sbx) {

    var treatments = filterTreatments(sbx);
    var lastMBG = sbx.lastEntry(sbx.data.mbgs);
    var lastTreatment = sbx.lastEntry(treatments);

    var mbgCurrent = isCurrent(lastMBG);
    var treatmentCurrent = isCurrent(lastTreatment);

    if (mbgCurrent || treatmentCurrent) {
      var mbgMessage = mbgCurrent ? 'Meter BG ' + sbx.scaleEntry(lastMBG) + ' ' + sbx.unitsLabel : '';
      var treatmentMessage = treatmentCurrent ? 'Treatment: ' + lastTreatment.eventType : '';
{'fraction_non_alphanumeric': 0.12848570420049418, 'fraction_numerical': 0.0010589481115425344, 'mean_word_length': 3.69983416252073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2621656', 'n_tokens_mistral': 904, 'n_tokens_neox': 826, 'n_words': 196}