<commit_before>/**
 * Created by aleckim on 2016. 5. 1..
 */

angular.module('service.push', [])
    .factory('Push', function($http, TwStorage, Util, WeatherUtil, WeatherInfo, $location, Units) {
        var obj = {};
        obj.config = {
            "android": {
                "senderID": twClientConfig.googleSenderId
                //"icon": "TodayWeather",
                //"iconColor": "blue"
                //"forceShow": true,
            },
            "ios": {
                "alert": "true",
                "badge": "true",
                "sound": "true",
                "clearBadge": "true"
            },
            "windows": {}
        };

        obj.pushUrl = twClientConfig.serverUrl + '/v000902'+'/push';
        obj.pushListUrl = twClientConfig.serverUrl + '/v000902'+'/push-list';

        /**
         *
         * @type {{registrationId: string, type: string, category: string, pushList: Array}}
         */
        obj.pushData = {registrationId: '', type: '', category:'', pushList: []};

        /**
         * units 변경시에 push 갱신 #1845
         */
        obj.updateUnits = function () {
            var self = this;
            if (self.pushData.pushList.length > 0) {
                Util.ga.trackEvent('push', 'update', 'units');
                self._postPushList(self.pushData.pushList);
            }
        };

        /**
         * alert 들어오기 전 format
         */
        obj.loadOldPushInfo = function () {
            var self = this;
            var pushData = TwStorage.get("pushData");
            if (pushData != null) {
                self.pushData.registrationId = pushData.registrationId;
                self.pushData.type = pushData.type;
                self.pushData.pushList = pushData.alarmList;
                self.pushData.pushList.forEach(function (pushInfo) {
                    pushInfo.time = new Date(pushInfo.time);
                    pushInfo.category = 'alarm';
                    pushInfo.id = pushInfo.cityIndex;
                });

                //update alarmInfo to server for sync
                if (self.pushData.pushList.length > 0) {
                    setTimeout(function() {
                        self._postPushList(self.pushData.pushList);
                    }, 3000);
                }
            }
            console.log('load push data');
            console.log(self);
        };

        /**
         * alert, alarm이 함께 pushList에 들어감
         */
        obj.loadPushInfo = function () {
            var self = this;
            var pushData = TwStorage.get("pushData2");<commit_msg>fix undefined of pushInfo from loadOldPushInfo<commit_after>/**
 * Created by aleckim on 2016. 5. 1..
 */

angular.module('service.push', [])
    .factory('Push', function($http, TwStorage, Util, WeatherUtil, WeatherInfo, $location, Units) {
        var obj = {};
        obj.config = {
            "android": {
                "senderID": twClientConfig.googleSenderId
                //"icon": "TodayWeather",
                //"iconColor": "blue"
                //"forceShow": true,
            },
            "ios": {
                "alert": "true",
                "badge": "true",
                "sound": "true",
                "clearBadge": "true"
            },
            "windows": {}
        };

        obj.pushUrl = twClientConfig.serverUrl + '/v000902'+'/push';
        obj.pushListUrl = twClientConfig.serverUrl + '/v000902'+'/push-list';

        /**
         *
         * @type {{registrationId: string, type: string, category: string, pushList: Array}}
         */
        obj.pushData = {registrationId: '', type: '', category:'', pushList: []};

        /**
         * units 변경시에 push 갱신 #1845
         */
        obj.updateUnits = function () {
            var self = this;
            if (self.pushData.pushList.length > 0) {
                Util.ga.trackEvent('push', 'update', 'units');
                self._postPushList(self.pushData.pushList);
            }
        };

        /**
         * alert 들어오기 전 format
         */
        obj.loadOldPushInfo = function () {
            var self = this;
            var pushData = TwStorage.get("pushData");
            if (pushData != null) {
                self.pushData.registrationId = pushData.registrationId;
                self.pushData.type = pushData.type;
                self.pushData.pushList = pushData.alarmList;
                self.pushData.pushList.forEach(function (pushInfo) {
                    pushInfo.time = new Date(pushInfo.time);
                    pushInfo.category = 'alarm';
                    pushInfo.id = pushInfo.cityIndex;
                    pushInfo.enable = true;
                    pushInfo.dayOfWeek = [true, true, true, true, true, true, true];
                });

                //update alarmInfo to server for sync
                if (self.pushData.pushList.length > 0) {
                    setTimeout(function() {
                        self._postPushList(self.pushData.pushList);
                    }, 3000);
                }
            }
            console.log('load push data');
            console.log(self);
        };

        /**
         * alert, alarm이 함께 pushList에 들어감
         */
        obj.loadPushInfo = function () {
            var self = this;
            var pushData = TwStorage.get("pushData2");
{'fraction_non_alphanumeric': 0.1308095952023988, 'fraction_numerical': 0.010869565217391304, 'mean_word_length': 1.367790594498669, 'pattern_counts': {'":': 22, '<': 3, '<?xml version=': 0, '>': 7, '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': '5873822', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1444, 'n_words': 284}