<commit_before>angular.module('mushin').factory('things', function ($rootScope, hoodie, $q, Thing) {

  var debug = new window.$debug('mushin:services/thing');
  $rootScope.contexts = {}; // context name -> obj with things, active, ...
  $rootScope.projects = {};
  $rootScope.importance = {}; // importance level -> obj with things, active, ...
  $rootScope.urgency = {};

  hoodie.store.on('change:thing', function(name, thing) {
    $rootScope.$broadcast('thingChange', {
      type: name,
      thing: thing
    })
  })

  // update the contexts/projects hash based on the thing
  var trackHash = function(hash, type, thing) {
    var plural = type + 's'

    if (thing[plural]) {
      for (var j = 0; j < thing[plural].length; ++j) {
        // for now, ignore completed things
        if (thing.complete == 100) { return; }

        var name = thing[plural][j];
        if (!(name in hash)) {
          hash[name] = {
            'name': name,
            'active': false,
            'things': [],
          }
        }

        hash[name].things.push(thing);
      }
    }
  }
  // update the importance/urgency hash based on the thing
  var trackNumberHash = function(hash, type, thing) {
    var number = thing[type];

    if (number) {
      if (!(number in hash)) {
        hash[number] = {
          'name': number,
          'active': false,
          'things': [],
        };
      }
      // for now, ignore completed things
      if (thing.complete == 100) { return; }

      hash[number].things.push(thing);
    }
  }

  var resetHash = function(hash) {
    for (var key in hash) {
      hash[key].things = [];
    }
  }

  return {
    get: function(id) {
      return $q.when(hoodie.store.find('thing', id));
    },
    getAll: function(type) {
      var promise = $q.when(hoodie.store.findAll('thing'));
      if (!Thing.isType(type)) {
        return promise;
      }

      var deferred = $q.defer()
      promise.then(function(thingsData) {
        var thingsDataOfType = [];

        // reset when we recount
        resetHash($rootScope.projects);
        resetHash($rootScope.contexts);<commit_msg>add semicolon<commit_after>angular.module('mushin').factory('things', function ($rootScope, hoodie, $q, Thing) {

  var debug = new window.$debug('mushin:services/thing');
  $rootScope.contexts = {}; // context name -> obj with things, active, ...
  $rootScope.projects = {};
  $rootScope.importance = {}; // importance level -> obj with things, active, ...
  $rootScope.urgency = {};

  hoodie.store.on('change:thing', function(name, thing) {
    $rootScope.$broadcast('thingChange', {
      type: name,
      thing: thing
    })
  })

  // update the contexts/projects hash based on the thing
  var trackHash = function(hash, type, thing) {
    var plural = type + 's'

    if (thing[plural]) {
      for (var j = 0; j < thing[plural].length; ++j) {
        // for now, ignore completed things
        if (thing.complete == 100) { return; }

        var name = thing[plural][j];
        if (!(name in hash)) {
          hash[name] = {
            'name': name,
            'active': false,
            'things': [],
          }
        }

        hash[name].things.push(thing);
      }
    }
  }
  // update the importance/urgency hash based on the thing
  var trackNumberHash = function(hash, type, thing) {
    var number = thing[type];

    if (number) {
      if (!(number in hash)) {
        hash[number] = {
          'name': number,
          'active': false,
          'things': [],
        };
      }
      // for now, ignore completed things
      if (thing.complete == 100) { return; }

      hash[number].things.push(thing);
    }
  }

  var resetHash = function(hash) {
    for (var key in hash) {
      hash[key].things = [];
    }
  }

  return {
    get: function(id) {
      return $q.when(hoodie.store.find('thing', id));
    },
    getAll: function(type) {
      var promise = $q.when(hoodie.store.findAll('thing'));
      if (!Thing.isType(type)) {
        return promise;
      }

      var deferred = $q.defer();

      promise.then(function(thingsData) {
        var thingsDataOfType = [];

        // reset when we recount
        resetHash($rootScope.projects);
        resetHash($rootScope.contexts);
{'fraction_non_alphanumeric': 0.15585331452750353, 'fraction_numerical': 0.003291020216267043, 'mean_word_length': 2.163568773234201, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2860722', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1295, 'n_words': 314}