<commit_before>'use strict';
angular.module('Trendicity')

.service('FavoritesService', function(localStorageService, GeolocationService) {
  // CREATE
  this.add = function (favorite) {
    var favorites = this.getFavorites() ? this.getFavorites() : [];
    var id = favorites.length + 1;

    if (favorite.city && favorite.region) {
      var address = favorite.city + ", " + favorite.region;
      return GeolocationService.addressToPosition(address).then(function (data) {
        var newLocation = {
          id: id,
          city: address,
          lat: data.latitude,
          lng: data.longitude
        };

        favorites.push(newLocation);
        localStorageService.set('Favorites', favorites);
      });
    } else {
      var newLocation = {
        id: id,
        city: favorite.city,
        lat: favorite.latitude,
        lng: favorite.longitude
      };

      favorites.push(newLocation);
      localStorageService.set('Favorites', favorites);
    }
  };

  // READ
  this.getFavorites = function () {
    return localStorageService.get('Favorites');
  };

  // DELETE
  this.delete = function (favorite) {
    var favorites = this.getFavorites();
    _.remove(favorites, favorite);
    localStorageService.set('Favorites', favorites);
    return this.getFavorites();
  };
});<commit_msg>favorite lat and lng attributes were incorrect fixes #56<commit_after>'use strict';
angular.module('Trendicity')

.service('FavoritesService', function(localStorageService, GeolocationService) {
  // CREATE
  this.add = function (favorite) {
    var favorites = this.getFavorites() ? this.getFavorites() : [];
    var id = favorites.length + 1;

    if (favorite.city && favorite.region) {
      var address = favorite.city + ", " + favorite.region;
      return GeolocationService.addressToPosition(address).then(function (data) {
        var newLocation = {
          id: id,
          city: address,
          lat: data.latitude,
          lng: data.longitude
        };
        favorites.push(newLocation);
        localStorageService.set('Favorites', favorites);
      });
    } else {
      var newLocation = {
        id: id,
        city: favorite.city,
        lat: favorite.lat,
        lng: favorite.lng
      };
      favorites.push(newLocation);
      localStorageService.set('Favorites', favorites);
    }
  };

  // READ
  this.getFavorites = function () {
    return localStorageService.get('Favorites');
  };

  // DELETE
  this.delete = function (favorite) {
    var favorites = this.getFavorites();
    _.remove(favorites, favorite);
    localStorageService.set('Favorites', favorites);
    return this.getFavorites();
  };
});
{'fraction_non_alphanumeric': 0.12960180315552217, 'fraction_numerical': 0.0015026296018031556, 'mean_word_length': 2.7037552155771905, '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': '1050520', 'n_tokens_mistral': 797, 'n_tokens_neox': 790, 'n_words': 154}