<commit_before>(function () {
  'use strict';

  angular
    .module('app.models', [])
    .factory('Box', BoxModel);

  BoxModel.$inject = ['Sensor', 'OpenSenseMapAPI'];

  function BoxModel (Sensor, OpenSenseMapAPI) {

    /**
     * Constructor
     * @param {*} box
     */
    function Box (box) {
      _copy(box, this);
    }

    /**
     * Public methods, assigned to prototype
     */
    Box.prototype = {
      getBadgeColor: function () {
        if (this.exposure === 'indoor') {
          return 'orange';
        } else {
          return 'olive';
        }
      },
      getArchiveLink: function () {
        return "https://archive.opensensemap.org/"+moment().subtract(1, 'days').format('YYYY-MM-DD')+"/"+this.id+"-"+doubleGermanS(this.name).replace(/[^A-Za-z0-9._-]/g,'_');
      },
      getLastMeasurement: function () {
        var that = this;
        OpenSenseMapAPI.getSensors(this._id)
          .then(function (response) {
            for (var index in response.sensors) {
              var sensor = response.sensors[index];

              that.sensors[sensor._id].lastMeasurement.value = sensor.lastMeasurement.value;
              that.sensors[sensor._id].lastMeasurement.createdAt = sensor.lastMeasurement.createdAt;
              // if (angular.isDefined(vm.sensordata[response.sensors[i]._id])) {
              //           var data = angular.copy(vm.sensordata[response.sensors[i]._id]);
              //           console.log(data);
              //           data.unshift(datapair);
              //           console.log(data.length)
              //           console.log(data);
              //           // remove first entry
              //           //todo check amount of data depending on selected time frame
              //           data.pop();
              //           console.log(data.length)
              //           vm.sensordata[response.sensors[i]._id] = data;
              //         }
            }
          })
          .catch(function (error) {
            return error;
          });
      }
    }

    /**
     * Private function
     * @param {*} value
     */
    var doubleGermanS = function (value) {
      value = value.replace(/ß/g, 'ßß');
      return value;
    }

    var _copy = function (srcObj, destObj) {
      for (var key in srcObj) {
        if (key === 'sensors') {
          destObj['sensors'] = {};
          for (var index in srcObj.sensors) {
            var sensor = new Sensor(srcObj.sensors[index]);
            destObj.sensors[sensor._id] = sensor;
          }
        } else {<commit_msg>fix regex in archive link<commit_after>(function () {
  'use strict';

  angular
    .module('app.models', [])
    .factory('Box', BoxModel);

  BoxModel.$inject = ['Sensor', 'OpenSenseMapAPI'];

  function BoxModel (Sensor, OpenSenseMapAPI) {

    /**
     * Constructor
     * @param {*} box
     */
    function Box (box) {
      _copy(box, this);
    }

    /**
     * Public methods, assigned to prototype
     */
    Box.prototype = {
      getBadgeColor: function () {
        if (this.exposure === 'indoor') {
          return 'orange';
        } else {
          return 'olive';
        }
      },
      getArchiveLink: function () {
        return "https://archive.opensensemap.org/"+moment().subtract(1, 'days').format('YYYY-MM-DD')+"/"+this._id+"-"+doubleGermanS(this.name).replace(/[^A-Za-z0-9._-]/g,'_');
      },
      getLastMeasurement: function () {
        var that = this;
        OpenSenseMapAPI.getSensors(this._id)
          .then(function (response) {
            for (var index in response.sensors) {
              var sensor = response.sensors[index];

              that.sensors[sensor._id].lastMeasurement.value = sensor.lastMeasurement.value;
              that.sensors[sensor._id].lastMeasurement.createdAt = sensor.lastMeasurement.createdAt;
              // if (angular.isDefined(vm.sensordata[response.sensors[i]._id])) {
              //           var data = angular.copy(vm.sensordata[response.sensors[i]._id]);
              //           console.log(data);
              //           data.unshift(datapair);
              //           console.log(data.length)
              //           console.log(data);
              //           // remove first entry
              //           //todo check amount of data depending on selected time frame
              //           data.pop();
              //           console.log(data.length)
              //           vm.sensordata[response.sensors[i]._id] = data;
              //         }
            }
          })
          .catch(function (error) {
            return error;
          });
      }
    }

    /**
     * Private function
     * @param {*} value
     */
    var doubleGermanS = function (value) {
      value = value.replace(/[\u00A0-\u10FFFF]/g, '__');
      return value;
    }

    var _copy = function (srcObj, destObj) {
      for (var key in srcObj) {
        if (key === 'sensors') {
          destObj['sensors'] = {};
          for (var index in srcObj.sensors) {
            var sensor = new Sensor(srcObj.sensors[index]);
            destObj.sensors[sensor._id] = sensor;
          }
        } else {
{'fraction_non_alphanumeric': 0.14395837348236654, 'fraction_numerical': 0.002119868953555598, 'mean_word_length': 1.551622418879056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4706493', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1471, 'n_words': 267}