<commit_before>'use strict';

pinpointApp.controller('FilteredMapCtrl', [ '$scope', '$routeParams', '$timeout', 'TimeSliderDao', 'NavbarDao', function ($scope, $routeParams, $timeout, TimeSliderDao, NavbarDao) {

    // define private variables
    var oNavbarDao, oTimeSliderDao;

    /**
     * initialize
     */
    $timeout(function () {
        oNavbarDao = new NavbarDao();
        if ($routeParams.application) {
            oNavbarDao.setApplication($routeParams.application);
        }
        if ($routeParams.period) {
            oNavbarDao.setPeriod(Number($routeParams.period, 10));
        }
        if ($routeParams.queryEndTime) {
            oNavbarDao.setQueryEndTime(Number($routeParams.queryEndTime, 10));
        }
        if ($routeParams.filter) {
            oNavbarDao.setFilter($routeParams.filter);
        }
        oNavbarDao.autoCalculateByQueryEndTimeAndPeriod();

        oTimeSliderDao = new TimeSliderDao()
            .setFrom(oNavbarDao.getQueryStartTime())
            .setTo(oNavbarDao.getQueryEndTime())
            .setInnerFrom(oNavbarDao.getQueryEndTime() - 1)
            .setInnerTo(oNavbarDao.getQueryEndTime());

        $timeout(function () {
            $scope.$emit('timeSlider.initialize', oTimeSliderDao);
            $scope.$emit('serverMap.initialize', oNavbarDao);
            $scope.$emit('scatter.initialize', oNavbarDao);
        });
    });

    /**
     * scope event on serverMap.fetched
     */
    $scope.$on('serverMap.fetched', function (event, lastFetchedTimestamp, nodeLength) {
        if (nodeLength === 0) {
            $scope.$emit('timeSlider.disableMore');
            oTimeSliderDao.setInnerFrom(oTimeSliderDao.getFrom());
        } else {
            oTimeSliderDao.setInnerFrom(lastFetchedTimestamp);
        }
        $scope.$emit('timeSlider.setInnerFromTo', oTimeSliderDao);
    });

    /**
     * scope event on serverMap. allFetched
     */
    $scope.$on('serverMap.allFetched', function (event) {
        oTimeSliderDao.setInnerFrom(oTimeSliderDao.getFrom());
        $scope.$emit('timeSlider.setInnerFromTo', oTimeSliderDao);
    });

    /**
     * scope event of timeSlider.moreClicked
     */
    $scope.$on('timeSlider.moreClicked', function (event) {
        oNavbarDao.setQueryEndTime(oTimeSliderDao.getInnerFrom());
        oNavbarDao.autoCalcultateByQueryStartTimeAndQueryEndTime();
        $scope.$emit('serverMap.initialize', oNavbarDao);
    });

    /**
     * scope event on serverMap.passingTransactionResponseToScatterChart
     */
    $scope.$on('serverMap.passingTransactionResponseToScatterChart', function (event, node) {
        $scope.$emit('scatter.initializeWithNode', node);
    });

    /**
     * scope event on serverMap.nodeClicked
     */
    $scope.$on('serverMap.nodeClicked', function (event, e, query, node, data) {
        $scope.$emit('nodeInfoDetails.initialize', e, query, node, data);
        $scope.$emit('linkInfoDetails.reset', e, query, node, data);
    });


    /**<commit_msg>[임대현] [NOBTS] filtermap, 데이터 로딩을 다했는데도, more 버튼이 활성화 되는 버그 수정<commit_after>'use strict';

pinpointApp.controller('FilteredMapCtrl', [ '$scope', '$routeParams', '$timeout', 'TimeSliderDao', 'NavbarDao', function ($scope, $routeParams, $timeout, TimeSliderDao, NavbarDao) {

    // define private variables
    var oNavbarDao, oTimeSliderDao;

    /**
     * initialize
     */
    $timeout(function () {
        oNavbarDao = new NavbarDao();
        if ($routeParams.application) {
            oNavbarDao.setApplication($routeParams.application);
        }
        if ($routeParams.period) {
            oNavbarDao.setPeriod(Number($routeParams.period, 10));
        }
        if ($routeParams.queryEndTime) {
            oNavbarDao.setQueryEndTime(Number($routeParams.queryEndTime, 10));
        }
        if ($routeParams.filter) {
            oNavbarDao.setFilter($routeParams.filter);
        }
        oNavbarDao.autoCalculateByQueryEndTimeAndPeriod();

        oTimeSliderDao = new TimeSliderDao()
            .setFrom(oNavbarDao.getQueryStartTime())
            .setTo(oNavbarDao.getQueryEndTime())
            .setInnerFrom(oNavbarDao.getQueryEndTime() - 1)
            .setInnerTo(oNavbarDao.getQueryEndTime());

        $timeout(function () {
            $scope.$emit('timeSlider.initialize', oTimeSliderDao);
            $scope.$emit('serverMap.initialize', oNavbarDao);
            $scope.$emit('scatter.initialize', oNavbarDao);
        });
    });

    /**
     * scope event on serverMap.fetched
     */
    $scope.$on('serverMap.fetched', function (event, lastFetchedTimestamp, nodeLength) {
        if (nodeLength === 0) {
            $scope.$emit('timeSlider.disableMore');
            oTimeSliderDao.setInnerFrom(oTimeSliderDao.getFrom());
        } else {
            oTimeSliderDao.setInnerFrom(lastFetchedTimestamp);
        }
        $scope.$emit('timeSlider.setInnerFromTo', oTimeSliderDao);
    });

    /**
     * scope event on serverMap. allFetched
     */
    $scope.$on('serverMap.allFetched', function (event) {
        oTimeSliderDao.setInnerFrom(oTimeSliderDao.getFrom());
        $scope.$emit('timeSlider.setInnerFromTo', oTimeSliderDao);
        $scope.$emit('timeSlider.disableMore');
    });

    /**
     * scope event of timeSlider.moreClicked
     */
    $scope.$on('timeSlider.moreClicked', function (event) {
        oNavbarDao.setQueryEndTime(oTimeSliderDao.getInnerFrom());
        oNavbarDao.autoCalcultateByQueryStartTimeAndQueryEndTime();
        $scope.$emit('serverMap.initialize', oNavbarDao);
    });

    /**
     * scope event on serverMap.passingTransactionResponseToScatterChart
     */
    $scope.$on('serverMap.passingTransactionResponseToScatterChart', function (event, node) {
        $scope.$emit('scatter.initializeWithNode', node);
    });

    /**
     * scope event on serverMap.nodeClicked
     */
    $scope.$on('serverMap.nodeClicked', function (event, e, query, node, data) {
        $scope.$emit('nodeInfoDetails.initialize', e, query, node, data);
        $scope.$emit('linkInfoDetails.reset', e, query, node, data);
    });


    /**
{'fraction_non_alphanumeric': 0.13829787234042554, 'fraction_numerical': 0.0019639934533551553, 'mean_word_length': 2.84098051539912, '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': '3949127', 'n_tokens_mistral': 1853, 'n_tokens_neox': 1944, 'n_words': 264}