<commit_before>﻿(function () {
    angular.module('GVA.Voting').factory('PollService', ['$location', '$http', function ($location, $http) {
        var self = this;

        var lastCheckedTimestamps = {};

        self.currentPollId = function () {
            var urlParams = $location.url().split("/");

            if (urlParams.length < 3)
                return;

            var pollId = urlParams[2];

            return pollId;
        }

        self.submitVote = function (pollId, votes, token, callback) {

            if (!pollId || !votes || !token) {
                return null;
            }

            $http({
                method: 'PUT',
                url: '/api/token/' + token + '/poll/' + pollId + '/vote',
                data: votes
            })
            .success(function (data, status) { if (callback) { callback(data, status) } })
            .error(function (data, status) { if (callback) { callback(data, status) } });
        }

        self.getPoll = function (pollId, callback) {

            if (!pollId) {
                return null;
            }

            $http({
                method: 'GET',
                url: '/api/poll/' + pollId
            })
            .success(function (data, status) { if (callback) { callback(data, status) } })
            .error(function (data, status) { if (callback) { callback(data, status) } });

        }

        self.getResults = function (pollId, callback, failureCallback) {

            if (!pollId) {
                return null;
            }

            if (!lastCheckedTimestamps[pollId])
            {
                lastCheckedTimestamps[pollId] = 0;
            }

            $http({
                method: 'GET',
                url: '/api/poll/' + pollId + '/vote?lastPoll=' + lastCheckedTimestamps[pollId]
            })
            .success(function (data, status) {  if (callback) { callback(data) } })
            .error(function (data, status) { if (failureCallback) { failureCallback(data, status) } });

            lastCheckedTimestamps[pollId] = Date.now();
        }

        self.getTokenVotes = function (pollId, token, callback) {

            if (!pollId || !token) {
                return null;
            }

            $http({
                method: 'GET',
                url: '/api/token/' + token + '/poll/' + pollId + '/vote'
            })
            .success(function (data, status) { if (callback) { callback(data, status) } })
            .error(function (data, status) { if (callback) { callback(data, status) } });

        }

        return self;
    }]);
})();<commit_msg>Poll service now uses failure callbacks<commit_after>﻿(function () {
    angular.module('GVA.Voting').factory('PollService', ['$location', '$http', function ($location, $http) {
        var self = this;

        var lastCheckedTimestamps = {};

        self.currentPollId = function () {
            var urlParams = $location.url().split("/");

            if (urlParams.length < 3)
                return;

            var pollId = urlParams[2];

            return pollId;
        }

        self.submitVote = function (pollId, votes, token, callback, failureCallback) {

            if (!pollId || !votes || !token) {
                return null;
            }

            $http({
                method: 'PUT',
                url: '/api/token/' + token + '/poll/' + pollId + '/vote',
                data: votes
            })
            .success(function (data, status) { if (callback) { callback(data) } })
            .error(function (data, status) { if (failureCallback) { failureCallback(data, status) } });
        }

        self.getPoll = function (pollId, callback, failureCallback) {

            if (!pollId) {
                return null;
            }

            $http({
                method: 'GET',
                url: '/api/poll/' + pollId
            })
            .success(function (data, status) { if (callback) { callback(data) } })
            .error(function (data, status) { if (failureCallback) { failureCallback(data, status) } });

        }

        self.getResults = function (pollId, callback, failureCallback) {

            if (!pollId) {
                return null;
            }

            if (!lastCheckedTimestamps[pollId])
            {
                lastCheckedTimestamps[pollId] = 0;
            }

            $http({
                method: 'GET',
                url: '/api/poll/' + pollId + '/vote?lastPoll=' + lastCheckedTimestamps[pollId]
            })
            .success(function (data, status) {  if (callback) { callback(data) } })
            .error(function (data, status) { if (failureCallback) { failureCallback(data, status) } });

            lastCheckedTimestamps[pollId] = Date.now();
        }

        self.getTokenVotes = function (pollId, token, callback, failureCallback) {

            if (!pollId || !token) {
                return null;
            }

            $http({
                method: 'GET',
                url: '/api/token/' + token + '/poll/' + pollId + '/vote'
            })
            .success(function (data, status) { if (callback) { callback(data) } })
            .error(function (data, status) { if (failureCallback) { failureCallback(data, status) } });

        }

        return self;
    }]);
})();
{'fraction_non_alphanumeric': 0.14240090174713507, 'fraction_numerical': 0.0011271839188427579, 'mean_word_length': 1.5280151946818614, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3634782', 'n_tokens_mistral': 1487, 'n_tokens_neox': 1408, 'n_words': 329}