<commit_before>'use strict';

(function () {
  angular.module('hutmap').

  controller('FilterCtrl', 
    ['$scope',
    function($scope) {

    // filter data binding

    $scope.season = {
      winter: true,
      summer: true,
    };

    $scope.shelterType = {
      'emergency shelters': {
        include: false,
        keywords: ['Emergency Shelter', 'Refuge']
      },
      'fire lookouts': {
        include: true,
        keywords: ['Fire Lookout']
      },
      'huts & yurts': {
        include: true,
        keywords: ['Hut', 'Yurt', 'Chickee', 'Lean-to', 'Wall Tent', 'Shelter']
      },
      'compounds': {
        include: true,
        keywords: ['Compound', 'Hostel', 'Tea House', 'Lodge', 'Chalet', 'Ranch']
      }
    };

    // filter function

    $scope.filter = function() {
      $scope.incLoading();
      var filteredHuts = {};
      var typeKeywords = getTypeKeywords();
      angular.forEach($scope.huts, function(hut) {
        if (
          matchSeason(hut) &&
          matchShelterType(hut, typeKeywords)
        ) {
          filteredHuts[hut.id] = hut;
        }
      });
      $scope.setFilteredHuts(filteredHuts);
      $scope.$broadcast('gmMarkersRedraw', 'huts');
      $scope.decLoading();
    };

    $scope.$watch('huts', function() {
      $scope.filter();
    });

    
    // filter function helpers
    
    function getTypeKeywords() {
      var keywords = [];
      angular.forEach($scope.shelterType, function(data, type) {
        if (data.include) {
          keywords = keywords.concat(data.keywords);
        }
      });
      return keywords;
    };


    // matchers
   
    function matchSeason(hut) {
      var season = $scope.season;
      if (!season.winter && !season.summer) {
        return true;
      } else {
        return (season.winter && hut.open_winter) ||
               (season.summer && hut.open_summer);
      }
    };

    function matchShelterType(hut, keywords) {
      var matchShelterType = false;
      angular.forEach(keywords, function(keyword) {
        if (~hut.types.indexOf(keyword)) {
          matchShelterType = true;
          return;
        }
      });
      return matchShelterType;
    };

  }]);
})();
<commit_msg>Fix bug in season filter.<commit_after>'use strict';

(function () {
  angular.module('hutmap').

  controller('FilterCtrl', 
    ['$scope',
    function($scope) {

    // filter data binding

    $scope.season = {
      winter: true,
      summer: true,
    };

    $scope.shelterType = {
      'emergency shelters': {
        include: false,
        keywords: ['Emergency Shelter', 'Refuge']
      },
      'fire lookouts': {
        include: true,
        keywords: ['Fire Lookout']
      },
      'huts & yurts': {
        include: true,
        keywords: ['Hut', 'Yurt', 'Chickee', 'Lean-to', 'Wall Tent', 'Shelter']
      },
      'compounds': {
        include: true,
        keywords: ['Compound', 'Hostel', 'Tea House', 'Lodge', 'Chalet', 'Ranch']
      }
    };

    // filter function

    $scope.filter = function() {
      $scope.incLoading();
      var filteredHuts = {};
      var typeKeywords = getTypeKeywords();
      angular.forEach($scope.huts, function(hut) {
        if (
          matchSeason(hut) &&
          matchShelterType(hut, typeKeywords)
        ) {
          filteredHuts[hut.id] = hut;
        }
      });
      $scope.setFilteredHuts(filteredHuts);
      $scope.$broadcast('gmMarkersRedraw', 'huts');
      $scope.decLoading();
    };

    $scope.$watch('huts', function() {
      $scope.filter();
    });

    
    // filter function helpers
    
    function getTypeKeywords() {
      var keywords = [];
      angular.forEach($scope.shelterType, function(data, type) {
        if (data.include) {
          keywords = keywords.concat(data.keywords);
        }
      });
      return keywords;
    };


    // matchers
   
    function matchSeason(hut) {
      var season = $scope.season;
      if (!season.winter && !season.summer) {
        return (!hut.open_winter && !hut.open_summer);
      } else {
        return (season.winter && hut.open_winter) ||
               (season.summer && hut.open_summer);
      }
    };

    function matchShelterType(hut, keywords) {
      var matchShelterType = false;
      angular.forEach(keywords, function(keyword) {
        if (~hut.types.indexOf(keyword)) {
          matchShelterType = true;
          return;
        }
      });
      return matchShelterType;
    };

  }]);
})();

{'fraction_non_alphanumeric': 0.15149486836233825, 'fraction_numerical': 0.0, 'mean_word_length': 1.9926568758344458, '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': '4540936', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1395, 'n_words': 259}