<commit_before>angular.module("dive-log", [])
       .controller("dive-log-controller", DiveLogController)
       .factory("diveLogService", diveLogService);

function DiveLogController($scope, diveLogService) {
  $scope.dives = [];
  $scope.errorMessage = "";
  $scope.isLoading = isLoading;
  $scope.refreshDives = refreshDives;

  var loading = false;

  function isLoading() {
    return loading;
  }

  function refreshDives() {
    loading = true;
    $scope.dives = [];
    diveLogService.getDives().then(function(data){
      $scope.dives = data;
      $scope.errorMessage = "";
      loading = false;
    }, function(error){
      $scope.errorMessage = error;
      loading = false;
    });
  }

}

function diveLogService($q) {
  var dives = [
    {
      site: "Instituto Tecnológico de Tepic",
      location: "Tepic, Nayarit México",
      depth: 72,
      time: 54
    },
    {
      site: "Plaza San Rafael",
      location: "Tepic, Nayarit México",
      depth: 54,
      time: 38
    },
    {
      site: "Universidad Autónoma de Nayarit",
      location: "Tepic, Nayarit México",
      depth: 98,
      time: 62
    }];
    var counter = 0;

    return {
      getDives: function() {
        var deferred = $q.defer();
        counter++;
        setTimeout(function(){
          if(counter % 3 == 0) {
            deferred.reject("Error: Call counter is " + counter);
          } else {
            deferred.resolve(dives);
          }
        }, 1000);
        return deferred.promise;
      }
    };

}
<commit_msg>Changing the service to get data from cloud<commit_after>angular.module("dive-log", [])
       .controller("dive-log-controller", DiveLogController)
       .factory("diveLogService", diveLogService)
       .constant("apiUrl", "http://unraveling-ng.azurewebsites.net/");

function DiveLogController($scope, diveLogService) {
  $scope.dives = [];
  $scope.errorMessage = "";
  $scope.isLoading = isLoading;
  $scope.refreshDives = refreshDives;

  var loading = false;

  function isLoading() {
    return loading;
  }

  function refreshDives() {
    loading = true;
    $scope.dives = [];
    diveLogService.getDives().then(function(data){
      $scope.dives = data.data;
      $scope.errorMessage = "";
      loading = false;
    }, function(error){
      $scope.errorMessage = error;
      loading = false;
    });
  }

}

function diveLogService($http, apiUrl) {
    return {
      getDives: function() {
        var url = apiUrl + "/api/backendtest/dives";
        return $http.get(url);
      }
    };
}

{'fraction_non_alphanumeric': 0.14072327044025157, 'fraction_numerical': 0.007468553459119497, 'mean_word_length': 2.448509485094851, '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': '1661339', 'n_tokens_mistral': 844, 'n_tokens_neox': 818, 'n_words': 161}