<commit_before>(function()
{
  angular
    .module('foosey')
    .factory('FooseyService', FooseyService);

  FooseyService.$inject = ['$http'];

  function FooseyService($http) 
  {
    // var url = "http://localhost:4005/v1/";
    var url = "http://api.foosey.futbol/v1/";

    return {
      getAllPlayers     : getAllPlayers,
      getPlayer         : getPlayer,
      getPlayersByID    : getPlayersByID,
      getPlayerGames    : getPlayerGames,
      getAllGames       : getAllGames,
      getGame           : getGame,
      getGamesByID      : getGamesByID,
      getGames          : getGames,
      getEloHistory     : getEloHistory,
      getBadges         : getBadges,
      addGame           : addGame,
      addPlayer         : addPlayer,
      editGame          : editGame, 
      editPlayer        : editPlayer,
      removeGame        : removeGame,
      update            : update
    }

    // filter is an argument to filter out inactive players
    // true will filter to just active players, false will not
    function getAllPlayers(filter)
    {
      return $http.get(url + 'players').then(
        function(response)
        {
          if (!filter) return response.data;
          response = _.filter(response.data, function(player)
          {
            return player.active;
          });
          return response;
        });
    }

    function getPlayer(playerID)
    {
      return $http.get(url + 'players/' + playerID);
    }

    function getPlayersByID(playerIDs)
    {
      return $http.get(url + 'players?ids=' + playerIDs);
    }

    function getPlayerGames(playerID, limit)
    {
      return $http.get(url + 'players/' + playerID + '/games' + (limit ? '?limit=' + limit : ''));
    }

    function getAllGames()
    {
      return $http.get(url + 'games').then(
        function (response)
        {
          return _.map(response.data, addDateInfo);
        });
    }

    function getGame(gameID)
    {
      return $http.get(url + 'games/' + gameID).then(
        function (response)
        {
          return _.map([response.data], addDateInfo);
        });
    }

    function getGamesByID(gameIDs)
    {
      return $http.get(url + 'games?ids=' + gameIDs).then(
        function (response)
        {
          return _.map(response.data, addDateInfo);
        });
    }

    function getGames(limit, offset)
    {
      return $http.get(url + 'games?limit=' + limit + '&offset=' + offset).then(
        function (response)
        {
          return _.map(response.data, addDateInfo);
        });
    }

    function addDateInfo(game)
    {
      var gameMoment = moment.unix(game.timestamp)

      game.date = gameMoment.format("MM/DD/YYYY");
      game.time = gameMoment.format("h:mma");
      return game;
    }

    function getAllEloHistory()
    {
      return $http.get(url + 'stats/elo');
    }

    function getEloHistory(playerID)
    {
      return $http.get(url + 'stats/elo/' + playerID).then(
        function(response)<commit_msg>Need the service as well :P<commit_after>(function()
{
  angular
    .module('foosey')
    .factory('FooseyService', FooseyService);

  FooseyService.$inject = ['$http'];

  function FooseyService($http) 
  {
    // var url = "http://localhost:4005/v1/";
    var url = "http://api.foosey.futbol/v1/";

    return {
      getAllPlayers     : getAllPlayers,
      getPlayer         : getPlayer,
      getPlayersByID    : getPlayersByID,
      getPlayerGames    : getPlayerGames,
      getAllGames       : getAllGames,
      getGame           : getGame,
      getGamesByID      : getGamesByID,
      getGames          : getGames,
      getEloHistory     : getEloHistory,
      getBadges         : getBadges,
      addGame           : addGame,
      addPlayer         : addPlayer,
      editGame          : editGame, 
      editPlayer        : editPlayer,
      removeGame        : removeGame,
      update            : update
    }

    // filter is an argument to filter out inactive players
    // true will filter to just active players, false will not
    function getAllPlayers(filter)
    {
      return $http.get(url + 'players').then(
        function(response)
        {
          if (!filter) return response.data;
          response = _.filter(response.data, function(player)
          {
            return player.active;
          });
          return response;
        });
    }

    function getPlayer(playerID)
    {
      return $http.get(url + 'players/' + playerID);
    }

    function getPlayersByID(playerIDs)
    {
      return $http.get(url + 'players?ids=' + playerIDs);
    }

    function getPlayerGames(playerID, limit)
    {
      return $http.get(url + 'players/' + playerID + '/games' + (limit ? '?limit=' + limit : ''));
    }

    function getAllGames()
    {
      return $http.get(url + 'games').then(
        function (response)
        {
          return _.map(response.data, addDateInfo);
        });
    }

    function getGame(gameID)
    {
      return $http.get(url + 'games/' + gameID).then(
        function (response)
        {
          return _.map([response.data], addDateInfo);
        });
    }

    function getGamesByID(gameIDs)
    {
      return $http.get(url + 'games?ids=' + gameIDs).then(
        function (response)
        {
          return _.map(response.data, addDateInfo);
        });
    }

    function getGames(limit, offset)
    {
      return $http.get(url + 'games?limit=' + limit + '&offset=' + offset).then(
        function (response)
        {
          return _.map(response.data, addDateInfo);
        });
    }

    function addDateInfo(game)
    {
      var gameMoment = moment.unix(game.timestamp)

      game.date = gameMoment.format("MM/DD/YYYY");
      game.time = gameMoment.format("h:mma");
      return game;
    }

    function getAllEloHistory()
    {
      return $http.get(url + 'stats/elo');
    }

    function getEloHistory(playerID, limit)
    {
      return $http.get(url + 'stats/elo/' + playerID + (limit ? '?limit=' + limit : '')).then(
        function(response)
{'fraction_non_alphanumeric': 0.12355467459530889, 'fraction_numerical': 0.0019821605550049554, 'mean_word_length': 1.9124579124579124, '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': '637412', 'n_tokens_mistral': 1901, 'n_tokens_neox': 1837, 'n_words': 361}