<commit_before>angular.module('travel.results', [])

.controller('ResultsController', function ($scope, $window, $rootScope, $state, CurrentInfo, Venues, City, Groups, Util) {
  $scope.venues = [];
  $scope.filteredVenues = [];
  $scope.city = null;
  $scope.heading = null;
  $scope.groups = [];


  ////////////////// GET ALL THE GROUPS OF A USER //////////////////////


  $scope.getGroups = function() {
    if (!$rootScope.currentUser || !$rootScope.currentUser._id) return;

    Groups.getGroups($rootScope.currentUser._id)
      .then(function(groupsInfo){
        $scope.groups = groupsInfo;
      });
  };


////////////////// SELECTING A GROUP WILL REROUTE TO RESULTS PAGE //////////////////////


  $scope.selectGroup = function(groupInfo) {
    Groups.selectGroup(groupInfo, $rootScope);
    $window.sessionStorage.setItem('knowhere', groupInfo.destination);
    $state.go('results');
  };


  ////////////////// FILTER FOR RESTAURANTS/ATTRACTIONS/HOTELS //////////////////////


  $scope.filterVenues = function (filterType) {
    var venues = [];

    // set heading to appropriate value
    if (filterType === 1) {
      $scope.heading = 'Hotels';
    } else if (filterType === 2) {
      $scope.heading = 'Restaurants';
    } else if (filterType === 3) {
      $scope.heading = 'Attractions';
    }

    // populate venues with appropriate results
    $scope.venues.forEach(function(venue) {
      if (venue.venue_type_id === filterType) {
        venues.push(venue);
      }
    });
    $scope.filteredVenues = venues;
  };


  ////////////////// GET ALL VENUES BASED ON A DESTINATION CITY //////////////////////


  $scope.getVenueInformation = function (permalink) {
    permalink = permalink || $window.sessionStorage.getItem('knowhere');
    if (!permalink) return;

    Venues.getVenues(permalink)
      .then(function(venueInfo) {
        if (!Array.isArray(venueInfo)) return;

        CurrentInfo.destination.venues = $scope.venues = venueInfo;
        $scope.filterVenues(1);
      })
      .catch(function(error){
        console.error(error);
      });
  };


  ////////////////// GET BASIC DESTINATION CITY INFO //////////////////////


  $scope.getCity = function (permalink) {
    permalink = permalink || $window.sessionStorage.getItem('knowhere');
    if (!permalink) return;

    City.getCity(permalink)
      .then(function(cityInfo) {
        $scope.city = cityInfo;
        CurrentInfo.destination.basicInfo = cityInfo;
    })
      .catch(function(error){
        console.error(error);
      });
  };



  ////////////////// ADD TO FAVORITE LIST //////////////////////


  $scope.addtoFavs = function(venueData) {
    venueData.userInfo = $rootScope.currentUser;
    venueData.groupInfo = $rootScope.currentGroup;
    venueData.rating = 5;
    Venues.rateVenue(venueData);
  };


  ////////////////// INIT STATE //////////////////////


  $scope.getGroups();
  $scope.getCity($window.sessionStorage.getItem('knowhere'));
  $scope.getVenueInformation($window.sessionStorage.getItem('knowhere'));


});
<commit_msg>(fix) Fix typo in ResultsController<commit_after>angular.module('travel.results', [])

.controller('ResultsController', function ($scope, $window, $rootScope, $state, CurrentInfo, Venues, City, Groups, Util) {
  $scope.venues = [];
  $scope.filteredVenues = [];
  $scope.city = null;
  $scope.heading = null;
  $scope.groups = [];


  ////////////////// GET ALL THE GROUPS OF A USER //////////////////////


  $scope.getGroups = function() {
    if (!$rootScope.currentUser || !$rootScope.currentUser._id) {
      return console.error("Cannot get groups. currentUser id not found!");
    }

    Groups.getGroups($rootScope.currentUser._id)
      .then(function(groupsInfo){
        $scope.groups = groupsInfo;
      });
  };


////////////////// SELECTING A GROUP WILL REROUTE TO RESULTS PAGE //////////////////////


  $scope.selectGroup = function(groupInfo) {
    Groups.selectGroup(groupInfo, $rootScope);
    $window.sessionStorage.setItem('knowhere', groupInfo.destination);
    $state.go('results');
  };


  ////////////////// FILTER FOR RESTAURANTS/ATTRACTIONS/HOTELS //////////////////////


  $scope.filterVenues = function (filterType) {
    var venues = [];

    // set heading to appropriate value
    if (filterType === 1) {
      $scope.heading = 'Hotels';
    } else if (filterType === 2) {
      $scope.heading = 'Restaurants';
    } else if (filterType === 3) {
      $scope.heading = 'Attractions';
    }

    // populate venues with appropriate results
    $scope.venues.forEach(function(venue) {
      if (venue.venue_type_id === filterType) {
        venues.push(venue);
      }
    });
    $scope.filteredVenues = venues;
  };


  ////////////////// GET ALL VENUES BASED ON A DESTINATION CITY //////////////////////


  $scope.getVenueInformation = function (permalink) {
    permalink = permalink || $window.sessionStorage.getItem('knowhere');
    if (!permalink) return;

    Venues.getVenues(permalink)
      .then(function(venueInfo) {
        if (!Array.isArray(venueInfo)) return;

        CurrentInfo.destination.venues = $scope.venues = venueInfo;
        $scope.filterVenues(1);
      })
      .catch(function(error){
        console.error(error);
      });
  };


  ////////////////// GET BASIC DESTINATION CITY INFO //////////////////////


  $scope.getCity = function (permalink) {
    permalink = permalink || $window.sessionStorage.getItem('knowhere');
    if (!permalink) return;

    City.getCity(permalink)
      .then(function(cityInfo) {
        $scope.city = cityInfo;
        CurrentInfo.destination.basicInfo = cityInfo;
    })
      .catch(function(error){
        console.error(error);
      });
  };



  ////////////////// ADD TO FAVORITE LIST //////////////////////


  $scope.addToFavs = function(venueData) {
    venueData.userInfo = $rootScope.currentUser;
    venueData.groupInfo = $rootScope.currentGroup;
    venueData.rating = 5;
    Venues.rateVenue(venueData);
  };


  ////////////////// INIT STATE //////////////////////


  $scope.getGroups();
  $scope.getCity($window.sessionStorage.getItem('knowhere'));
  $scope.getVenueInformation($window.sessionStorage.getItem('knowhere'));


});

{'fraction_non_alphanumeric': 0.21596774193548388, 'fraction_numerical': 0.0016129032258064516, 'mean_word_length': 2.2196261682242993, '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': '4802382', 'n_tokens_mistral': 1921, 'n_tokens_neox': 1798, 'n_words': 333}