<commit_before>var currentLocation;
var apiFilter = "allAPIs";
var statsEnabled = isDataPublishingEnabled();
currentLocation = window.location.pathname;

//setting default date
var to = new Date();
var from = new Date(to.getTime() - 1000 * 60 * 60 * 24 * 30);

jagg.post("/site/blocks/stats/api-last-access-times/ajax/stats.jag", { action: "getFirstAccessTime", currentLocation: currentLocation  },
        function (json) {

            if (!json.error) {
                if (json.usage && json.usage.length > 0) {
                    var d = new Date();
                    var firstAccessDay = new Date(json.usage[0].year, json.usage[0].month - 1, json.usage[0].day);
                    var currentDay = new Date(d.getFullYear(), d.getMonth(), d.getDate(),d.getHours(),d.getMinutes());


                        //day picker
                        $('#today-btn').on('click',function(){
                            getDateTime(currentDay,currentDay-86400000);

                        });

                        //hour picker
                        $('#hour-btn').on('click',function(){
                            getDateTime(currentDay,currentDay-3600000);
                        })

                        //week picker
                        $('#week-btn').on('click',function(){
                            getDateTime(currentDay,currentDay-604800000);
                        })

                        //month picker
                        $('#month-btn').on('click',function(){
                            getDateTime(currentDay,currentDay-(604800000*4));
                        });

                        $('#date-pick').click(function(){
                             $(this).removeClass('active');
                        });

                        //date picker
                        $('#date-pick').daterangepicker({
                              timePicker: true,
                              timePickerIncrement: 30,
                              format: 'YYYY-MM-DD h:mm',
                              opens: 'left',
                        });
                        
                        $("#apiFilter").change(function (e) {
                        	apiFilter = this.value;
                        	drawProviderAPIVersionUserLastAccess(from,to,apiFilter);
                        });

                        $('#date-pick').on('apply.daterangepicker', function(ev, picker) {
                           btnActiveToggle(this);
                           from = convertTimeString(picker.startDate);
                           to = convertTimeString(picker.endDate);
                           var fromStr = from.split(" ");
                           var toStr = to.split(" ");
                           var dateStr = fromStr[0] + " <i>" + fromStr[1] + "</i> <b>to</b> " + toStr[0] + " <i>" + toStr[1] + "</i>";
                           $("#date-pick span").html(dateStr);
                           drawProviderAPIVersionUserLastAccess(from,to,apiFilter);
                        });                        

                        getDateTime(to,from);


                        $('#date-pick').click(function (event) {
                        event.stopPropagation();
                        });

                        $('body').on('click', '.btn-group button', function (e) {
                            $(this).addClass('active');
                            $(this).siblings().removeClass('active');
                        });

                }

                else if (json.usage && json.usage.length == 0 && statsEnabled) {
                    $('.stat-page').html("");
                    $('.stat-page').append($('<br><div class="errorWrapper"><img src="../themes/wso2/templates/images/statsEnabledThumb.png" alt="Thumbnail image when stats enabled"></div>'));
                }

                else{
                    $('.stat-page').html("");
                    $('.stat-page').append($('<br><div class="errorWrapper"><span class="top-level-warning"><span class="glyphicon glyphicon-warning-sign blue"></span>'
                        +i18n.t('errorMsgs.checkBAMConnectivity')+'</span><br/><img src="../themes/wso2/images/statsThumb.png" alt="Thumbnail image when stats not configured"></div>'));
                }
            }
            else {
                if (json.message == "AuthenticateError") {
                    jagg.showLogin();
                } else {
                    jagg.message({content: json.message, type: "error"});
                }
            }

        }, "json");


var drawProviderAPIVersionUserLastAccess = function(from,to,apiFilter){
    var fromDate = from;
    var toDate = to;
    jagg.post("/site/blocks/stats/api-last-access-times/ajax/stats.jag", { action:"getProviderAPIVersionUserLastAccess",currentLocation:currentLocation,fromDate:fromDate,toDate:toDate,apiFilter:apiFilter  },
        function (json) {
            $('#spinner').hide();
            if (!json.error) {
                var length = json.usage.length;
                $('#noData').empty();
                $('div#lastAccessTable_wrapper.dataTables_wrapper.no-footer').remove();

                var $dataTable =$('<table class="display table table-striped table-bordered" width="100%" cellspacing="0" id="lastAccessTable"></table>');<commit_msg>fixed wrong image path<commit_after>var currentLocation;
var apiFilter = "allAPIs";
var statsEnabled = isDataPublishingEnabled();
currentLocation = window.location.pathname;

//setting default date
var to = new Date();
var from = new Date(to.getTime() - 1000 * 60 * 60 * 24 * 30);

jagg.post("/site/blocks/stats/api-last-access-times/ajax/stats.jag", { action: "getFirstAccessTime", currentLocation: currentLocation  },
        function (json) {

            if (!json.error) {
                if (json.usage && json.usage.length > 0) {
                    var d = new Date();
                    var firstAccessDay = new Date(json.usage[0].year, json.usage[0].month - 1, json.usage[0].day);
                    var currentDay = new Date(d.getFullYear(), d.getMonth(), d.getDate(),d.getHours(),d.getMinutes());


                        //day picker
                        $('#today-btn').on('click',function(){
                            getDateTime(currentDay,currentDay-86400000);

                        });

                        //hour picker
                        $('#hour-btn').on('click',function(){
                            getDateTime(currentDay,currentDay-3600000);
                        })

                        //week picker
                        $('#week-btn').on('click',function(){
                            getDateTime(currentDay,currentDay-604800000);
                        })

                        //month picker
                        $('#month-btn').on('click',function(){
                            getDateTime(currentDay,currentDay-(604800000*4));
                        });

                        $('#date-pick').click(function(){
                             $(this).removeClass('active');
                        });

                        //date picker
                        $('#date-pick').daterangepicker({
                              timePicker: true,
                              timePickerIncrement: 30,
                              format: 'YYYY-MM-DD h:mm',
                              opens: 'left',
                        });
                        
                        $("#apiFilter").change(function (e) {
                        	apiFilter = this.value;
                        	drawProviderAPIVersionUserLastAccess(from,to,apiFilter);
                        });

                        $('#date-pick').on('apply.daterangepicker', function(ev, picker) {
                           btnActiveToggle(this);
                           from = convertTimeString(picker.startDate);
                           to = convertTimeString(picker.endDate);
                           var fromStr = from.split(" ");
                           var toStr = to.split(" ");
                           var dateStr = fromStr[0] + " <i>" + fromStr[1] + "</i> <b>to</b> " + toStr[0] + " <i>" + toStr[1] + "</i>";
                           $("#date-pick span").html(dateStr);
                           drawProviderAPIVersionUserLastAccess(from,to,apiFilter);
                        });                        

                        getDateTime(to,from);


                        $('#date-pick').click(function (event) {
                        event.stopPropagation();
                        });

                        $('body').on('click', '.btn-group button', function (e) {
                            $(this).addClass('active');
                            $(this).siblings().removeClass('active');
                        });

                }

                else if (json.usage && json.usage.length == 0 && statsEnabled) {
                    $('.stat-page').html("");
                    $('.stat-page').append($('<br><div class="errorWrapper"><img src="../themes/wso2/images/statsEnabledThumb.png" alt="Thumbnail image when stats enabled"></div>'));
                }

                else{
                    $('.stat-page').html("");
                    $('.stat-page').append($('<br><div class="errorWrapper"><span class="top-level-warning"><span class="glyphicon glyphicon-warning-sign blue"></span>'
                        +i18n.t('errorMsgs.checkBAMConnectivity')+'</span><br/><img src="../themes/wso2/images/statsThumb.png" alt="Thumbnail image when stats not configured"></div>'));
                }
            }
            else {
                if (json.message == "AuthenticateError") {
                    jagg.showLogin();
                } else {
                    jagg.message({content: json.message, type: "error"});
                }
            }

        }, "json");


var drawProviderAPIVersionUserLastAccess = function(from,to,apiFilter){
    var fromDate = from;
    var toDate = to;
    jagg.post("/site/blocks/stats/api-last-access-times/ajax/stats.jag", { action:"getProviderAPIVersionUserLastAccess",currentLocation:currentLocation,fromDate:fromDate,toDate:toDate,apiFilter:apiFilter  },
        function (json) {
            $('#spinner').hide();
            if (!json.error) {
                var length = json.usage.length;
                $('#noData').empty();
                $('div#lastAccessTable_wrapper.dataTables_wrapper.no-footer').remove();

                var $dataTable =$('<table class="display table table-striped table-bordered" width="100%" cellspacing="0" id="lastAccessTable"></table>');
{'fraction_non_alphanumeric': 0.1447356062740678, 'fraction_numerical': 0.012397858551704706, 'mean_word_length': 1.3573168031879566, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3323017', 'n_tokens_mistral': 2770, 'n_tokens_neox': 2565, 'n_words': 408}