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

  angular
    .module('porttare.controllers')
    .controller('CourierController', CourierController);

  function CourierController(CourierService,
                            $ionicPopup,
                            $state,
                            $auth,
                            $ionicLoading,
                            $ionicScrollDelegate) {
    var courierVm = this;
    var stateRedirect = 'courier.orders';

    courierVm.submit = submit;
    courierVm.step = 1;
    courierVm.createCourier = createCourier;
    courierVm.messages = {};
    initCourier();

    courierVm.locations = [
      'Loja',
      'Quito'
    ];
    courierVm.licenses = [
      'A',
      'A1',
      'B',
      'C1',
      'C',
      'D1',
      'D',
      'E1',
      'E',
      'F',
      'G'
    ];
    courierVm.mobilization = [
      'Motocicleta particular',
      'Motocicleta comercial',
      'Automóvil particular',
      'Automóvil estatal',
      'Automóvil comercial',
      'Bus escolar / turismo',
      'Bus pasajeros',
      'Pesado',
      'Especiales'
    ];

    function initCourier(){
      courierVm.courier = {};
      courierVm.courier.nombres = $auth.user.name;
      courierVm.courier.email = $auth.user.email;
    }

    function createCourier() {
      $ionicLoading.show({
        template: '{{::("globals.sending"|translate)}}'
      });

      CourierService.createNewCourier(courierVm.courier)
        .then(function success(courier) {
          //update auth user
          $auth.user.courier_profile = courier.courier_profile; //jshint ignore:line
          $ionicLoading.hide();
          $state.go(stateRedirect).then(function () {
            $ionicPopup.alert({
              title: 'Alerta',
              template: '{{::("courier.successCourierSave"|translate)}}'
            });
          });
        },
        function error(resp) {
          if (resp && resp.errors) {
            courierVm.messages = resp.errors;
          }
          $ionicLoading.hide();
        });
    }

    function submit() {
      if(courierVm.step === 2){
        createCourier();
      }
      courierVm.step += 1;
      $ionicScrollDelegate.scrollTop();
    }
  }
})();
<commit_msg>attempt to rescue when something goes wrong<commit_after>(function () {
  'use strict';

  angular
    .module('porttare.controllers')
    .controller('CourierController', CourierController);

  function CourierController(CourierService,
                            $ionicPopup,
                            $state,
                            $auth,
                            $ionicLoading,
                            $ionicScrollDelegate) {
    var courierVm = this;
    var stateRedirect = 'courier.orders';

    courierVm.submit = submit;
    courierVm.step = 1;
    courierVm.createCourier = createCourier;
    courierVm.messages = {};
    initCourier();

    courierVm.locations = [
      'Loja',
      'Quito'
    ];
    courierVm.licenses = [
      'A',
      'A1',
      'B',
      'C1',
      'C',
      'D1',
      'D',
      'E1',
      'E',
      'F',
      'G'
    ];
    courierVm.mobilization = [
      'Motocicleta particular',
      'Motocicleta comercial',
      'Automóvil particular',
      'Automóvil estatal',
      'Automóvil comercial',
      'Bus escolar / turismo',
      'Bus pasajeros',
      'Pesado',
      'Especiales'
    ];

    function initCourier(){
      courierVm.courier = {};
      courierVm.courier.nombres = $auth.user.name;
      courierVm.courier.email = $auth.user.email;
    }

    function createCourier() {
      $ionicLoading.show({
        template: '{{::("globals.sending"|translate)}}'
      });

      CourierService.createNewCourier(courierVm.courier)
        .then(function success(courier) {
          //update auth user
          $auth.user.courier_profile = courier.courier_profile; //jshint ignore:line
          $ionicLoading.hide();
          $state.go(stateRedirect).then(function () {
            $ionicPopup.alert({
              title: 'Alerta',
              template: '{{::("courier.successCourierSave"|translate)}}'
            });
          });
        },
        function error(resp) {
          courierVm.step = 1;
          if (resp && resp.errors) {
            courierVm.messages = resp.errors;
          }
          $ionicLoading.hide();
        });
    }

    function submit() {
      if(courierVm.step === 2){
        createCourier();
      }
      courierVm.step += 1;
      $ionicScrollDelegate.scrollTop();
    }
  }
})();

{'fraction_non_alphanumeric': 0.13460693895476505, 'fraction_numerical': 0.0032938076416337285, 'mean_word_length': 1.7324535092981403, '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': '3945070', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1409, 'n_words': 220}