<commit_before>'use strict';

/* Services */

angular.module('myApp.services', [])

    .value('FIREBASE_URL', 'https://waitandeat-demo-ver1.firebaseio.com/')
    // Preferred way to make a service
    // .factory('FIREBASE_URL', function() {
    //     return 'https://waitandeat-demo-ver1.firebaseio.com/';
    // });

	.factory('dataService', function ($firebase, FIREBASE_URL) {
		var dataRef =  new Firebase(FIREBASE_URL);
		var fireData = $firebase(dataRef);

		return fireData;
	})


	.factory('partyService', function(dataService){
    	var parties = dataService.$child('parties');

    	var partyServiceObject = {
    		parties: parties,
    		saveParty: function (party) {
				parties.$add(party);
    		}
    	};
    	return partyServiceObject;
	})

	.factory('textMessageService', function($firebase, FIREBASE_URL, partyService){
		var textMessageRef = new Firebase(FIREBASE_URL + 'textMessages');
        var textMessages = $firebase(textMessageRef);

        var textMessageObject = {
        	sendTextMessage: function (party) {
	        	var newTextMessage = {
		        	phoneNumber: party.phone,
		            size: party.size,
		            name: party.name
	        	};
	        	textMessages.$add(newTextMessage);
		        party.notified = 'Yes';
		        partyService.parties.$save(party.$id);
        	}
        };

        return textMessageObject;

   
	})


	.factory('authService', function($firebaseSimpleLogin, $location, $rootScope, FIREBASE_URL) {
		var authRef = new Firebase(FIREBASE_URL);
    	var auth = $firebaseSimpleLogin(authRef);

        var authServiceObject = {
        	register: function (user) {
        		auth.$createUser(user.email, user.password)
		            .then(function(data) {
                console.log(data);
                authServiceObject.login(user);
            });
        	},
            login: function(user) {
                auth.$login('password', user)
                    .then(function(data) {
                            console.log(data);
                            $location.path('/waitlist');
                        });
                    },
            logout: function () {
            	   		auth.$logout();
       				 	$location.path('/');
            }
        };

        $rootScope.$on("$firebaseSimpleLogin:login", function (e, user) {
        	$rootScope.currentUser = user;
        });

        $rootScope.$on("$firebaseSimpleLogin:logout", function () {
        	$rootScope.currentUser = null;
        });

        return authServiceObject;
       });<commit_msg>refactored text message service and injected data service<commit_after>'use strict';

/* Services */

angular.module('myApp.services', [])

    .value('FIREBASE_URL', 'https://waitandeat-demo-ver1.firebaseio.com/')
    // Preferred way to make a service
    // .factory('FIREBASE_URL', function() {
    //     return 'https://waitandeat-demo-ver1.firebaseio.com/';
    // });

	.factory('dataService', function ($firebase, FIREBASE_URL) {
		var dataRef =  new Firebase(FIREBASE_URL);
		var fireData = $firebase(dataRef);

		return fireData;
	})


	.factory('partyService', function(dataService){
    	var parties = dataService.$child('parties');

    	var partyServiceObject = {
    		parties: parties,
    		saveParty: function (party) {
				parties.$add(party);
    		}
    	};
    	return partyServiceObject;
	})

	.factory('textMessageService', function (dataService, partyService){

        var textMessages = dataService.$child('textMessages');

        var textMessageObject = {
        	sendTextMessage: function (party) {
	        	var newTextMessage = {
		        	phoneNumber: party.phone,
		            size: party.size,
		            name: party.name
	        	};
	        	textMessages.$add(newTextMessage);
		        party.notified = 'Yes';
		        partyService.parties.$save(party.$id);
        	}
        };

        return textMessageObject;

   
	})


	.factory('authService', function($firebaseSimpleLogin, $location, $rootScope, FIREBASE_URL) {
		var authRef = new Firebase(FIREBASE_URL);
    	var auth = $firebaseSimpleLogin(authRef);

        var authServiceObject = {
        	register: function (user) {
        		auth.$createUser(user.email, user.password)
		            .then(function(data) {
                console.log(data);
                authServiceObject.login(user);
            });
        	},
            login: function(user) {
                auth.$login('password', user)
                    .then(function(data) {
                            console.log(data);
                            $location.path('/waitlist');
                        });
                    },
            logout: function () {
            	   		auth.$logout();
       				 	$location.path('/');
            }
        };

        $rootScope.$on("$firebaseSimpleLogin:login", function (e, user) {
        	$rootScope.currentUser = user;
        });

        $rootScope.$on("$firebaseSimpleLogin:logout", function () {
        	$rootScope.currentUser = null;
        });

        return authServiceObject;
       });
{'fraction_non_alphanumeric': 0.1312635095303596, 'fraction_numerical': 0.0007860090391039497, 'mean_word_length': 1.967930029154519, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '1258100', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1446, 'n_words': 242}