<commit_before>import Bluebird from 'bluebird';

class GeocoderService {
    constructor() {
        this._geocoder = new google.maps.Geocoder();
    }

    getLocationFromAddress(address) {
        return new Bluebird((resolve, reject) => {
            this._geocoder.geocode({'address': address}, function(results, status) {
                if (status === google.maps.GeocoderStatus.OK) {
                    if (typeof results[0].address_components == 'undefined') {
                        return reject();
                    }
                    var components = {};
                    results[0].address_components.forEach(v1 => {
                        v1.types.forEach(v2 => {
                            components[v2] = v1.long_name;
                        });
                    });
                    return resolve({
                        latitude: results[0].geometry.location.lat(),
                        longitude: results[0].geometry.location.lng(),
                        address: results[0].formatted_address,
                        locality: components.locality || 'N/A',
                        country: components.country || 'N/A'
                    });
                } else {
                    return reject(status);
                }
            });
        });
    }

    getLocationFromCoords(lat, lng) {
        return new Bluebird((resolve, reject) => {
            var latLng = new google.maps.LatLng(parseFloat(lat), parseFloat(lng));
            this._geocoder.geocode({
                'latLng': latLng
            }, function (results, status) {
                if (status === google.maps.GeocoderStatus.OK) {
                    if (typeof results[0].address_components == 'undefined') {
                        return reject();
                    }
                    var components = {};
                    results[0].address_components.forEach(v1 => {
                        v1.types.forEach(v2 => {
                            components[v2] = v1.long_name;
                        });
                    });

                    return resolve({
                        latitude: results[0].geometry.location.lat(),
                        longitude: results[0].geometry.location.lng(),
                        address: results[0].formatted_address,
                        locality: components.locality || 'N/A',
                        country: components.country || 'N/A'
                    });
                } else {<commit_msg>Reject getLocation when no parameters (fix ask location if void on registration)<commit_after>import Bluebird from 'bluebird';

class GeocoderService {
    constructor() {
        this._geocoder = new google.maps.Geocoder();
    }

    getLocationFromAddress(address) {
        return new Bluebird((resolve, reject) => {
            if (!address) {
                return reject();
            }
            this._geocoder.geocode({'address': address}, function(results, status) {
                if (status === google.maps.GeocoderStatus.OK) {
                    if (typeof results[0].address_components == 'undefined') {
                        return reject();
                    }
                    var components = {};
                    results[0].address_components.forEach(v1 => {
                        v1.types.forEach(v2 => {
                            components[v2] = v1.long_name;
                        });
                    });
                    return resolve({
                        latitude: results[0].geometry.location.lat(),
                        longitude: results[0].geometry.location.lng(),
                        address: results[0].formatted_address,
                        locality: components.locality || 'N/A',
                        country: components.country || 'N/A'
                    });
                } else {
                    return reject(status);
                }
            });
        });
    }

    getLocationFromCoords(lat, lng) {
        return new Bluebird((resolve, reject) => {
            if (!lat || !lng) {
                return reject();
            }
            var latLng = new google.maps.LatLng(parseFloat(lat), parseFloat(lng));
            this._geocoder.geocode({
                'latLng': latLng
            }, function (results, status) {
                if (status === google.maps.GeocoderStatus.OK) {
                    if (typeof results[0].address_components == 'undefined') {
                        return reject();
                    }
                    var components = {};
                    results[0].address_components.forEach(v1 => {
                        v1.types.forEach(v2 => {
                            components[v2] = v1.long_name;
                        });
                    });

                    return resolve({
                        latitude: results[0].geometry.location.lat(),
                        longitude: results[0].geometry.location.lng(),
                        address: results[0].formatted_address,
                        locality: components.locality || 'N/A',
                        country: components.country || 'N/A'
                    });
                } else {
{'fraction_non_alphanumeric': 0.11179290508149568, 'fraction_numerical': 0.007670182166826462, 'mean_word_length': 1.1607290803645403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '228788', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1190, 'n_words': 216}