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

  angular
    .module('trips')
    .controller('TripsListController', TripsListController);

  TripsListController.$inject = ['TripsService', 'Authentication'];

  function TripsListController(TripsService, Authentication) {
    var vm = this;
    vm.authentication = Authentication;

    var trips = TripsService.query();

    trips.$promise.then(function(){
      console.log(vm.authentication.user._id + " is the auth user id");
      //return only the trips which have the current user as a passenger
      for (var trip in trips) {
        console.log(trip + " is the trip");
        for (var passenger in trip.passengers) {
          console.log(passenger + " is the passenger");
          console.log(passenger._id + " is the passenger ID");
          if (vm.authentication.user._id !== passenger._id) {
            var index = vm.trips.indexOf(trip);
            if (index > -1) {
              console.log("Got to the splicing part");
              trips.splice(index, 1);
            }
          }
        }
      }
      vm.trips = trips;
    });
}
})();
<commit_msg>Working with the promise pattern<commit_after>(function () {
  'use strict';

  angular
    .module('trips')
    .controller('TripsListController', TripsListController);

  TripsListController.$inject = ['TripsService', 'Authentication'];

  function TripsListController(TripsService, Authentication) {
    var vm = this;
    vm.authentication = Authentication;
    var trips;
    //http://blog.ninja-squad.com/2015/05/28/angularjs-promises/
    TripsService.query().then(function(response) {
      var trips = response.data;
    });

      console.log(vm.authentication.user._id + " is the auth user id");
      //return only the trips which have the current user as a passenger
      for (var trip in trips) {
        console.log(trip + " is the trip");
        for (var passenger in trip.passengers) {
          console.log(passenger + " is the passenger");
          console.log(passenger._id + " is the passenger ID");
          if (vm.authentication.user._id !== passenger._id) {
            var index = vm.trips.indexOf(trip);
            if (index > -1) {
              console.log("Got to the splicing part");
              trips.splice(index, 1);
            }
          }
        }
      }
      vm.trips = trips;
}
})();

{'fraction_non_alphanumeric': 0.1272264631043257, 'fraction_numerical': 0.005089058524173028, 'mean_word_length': 2.3366336633663365, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '374313', 'n_tokens_mistral': 695, 'n_tokens_neox': 669, 'n_words': 169}