<commit_before>// ==========================================================================
// Project:   EurekaJView.chartGridController
// Copyright: ©2010 My Company, Inc.
// ==========================================================================
/*globals EurekaJView */

/** @class

        (Document Your Controller Here)

 @extends SC.Object
 */
EurekaJView.chartGridController = SC.ArrayController.create(
/** @scope EurekaJView.chartGridController.prototype */
{

    timer: null,
    selectedChartTimespan: 10,
    selectedChartResolution: 15,
    selectedChartFrom: SC.DateTime.create(),
    selectedChartTo: SC.DateTime.create(),
    selectedChartFromString: null,
    selectedChartToString: null,
    dateFormat: '%d/%m/%Y %H:%M',
    showHistoricalData: NO,
    nowShowingTab: null,

    init: function() {
        var fromDate = this.get('selectedChartFrom').advance({minute: -10});
        if (fromDate) {
            this.set('selectedChartFrom', fromDate);
        }
        this.generateChartStrings();
    },

    nowShowingTabChange: function() {
        SC.Logger.log('TAB CHANGED TO: ' + this.get('nowShowingTab'));
        if (this.get('nowShowingTab') === 'EurekaJView.HistoricalStatisticsOptionsView') {
            this.set('showHistoricalData', YES);
        } else if (this.get('nowShowingTab') === 'EurekaJView.LiveStatisticsOptionsView') {
            this.set('showHistoricalData', NO);
        }

        this.refreshData();
    }.observes('nowShowingTab'),

    orderBy: 'name',

    observeChartFromChange: function() {
        var parsedDate = SC.DateTime.parse(this.get('selectedChartFromString'), this.get('dateFormat'));
        SC.Logger.log('From Date parsed to: ' + parsedDate);
        if (parsedDate) {
            this.set('selectedChartFrom', parsedDate);
            this.refreshData();
        }
    }.observes('selectedChartFromString'),

    observeChartToChange: function() {
        var parsedDate =  SC.DateTime.parse(this.get('selectedChartToString'), this.get('dateFormat'));
        SC.Logger.log('To Date parsed to: ' + parsedDate);
        if (parsedDate) {

            this.set('selectedChartFrom', parsedDate);
            this.refreshData();
        }
    }.observes('selectedChartToString'),

    generateChartStrings: function() {
        this.set('selectedChartFromString', this.generateChartString(this.get('selectedChartFrom')));
        this.set('selectedChartToString', this.generateChartString(this.get('selectedChartTo')));
    },

    selectedChartFromMsProperty: function() {
        this.get('selectedChartFrom').get('milliseconds');
    }.property(),

    selectedChartToMsProperty: function() {
        this.get('selectedChartTo').get('milliseconds');
    }.property(),

    generateChartString: function(date) {
        var fmt = this.get('dateFormat') || '%m/%d/%Y';
        var dateString = date ? date.toFormattedString(fmt) : "";
        return dateString;
    },

    refreshData: function() {
        if (this.get('content')) {
            this.get('content').forEach(function(item, index, enumerable) {<commit_msg>Date validation to make sure selected dates are valid. <commit_after>// ==========================================================================
// Project:   EurekaJView.chartGridController
// Copyright: ©2010 My Company, Inc.
// ==========================================================================
/*globals EurekaJView */

/** @class

        (Document Your Controller Here)

 @extends SC.Object
 */
EurekaJView.chartGridController = SC.ArrayController.create(
/** @scope EurekaJView.chartGridController.prototype */
{

    timer: null,
    selectedChartTimespan: 10,
    selectedChartResolution: 15,
    selectedChartFrom: SC.DateTime.create(),
    selectedChartTo: SC.DateTime.create(),
    selectedChartFromString: null,
    selectedChartToString: null,
    dateFormat: '%d/%m/%Y %H:%M',
    showHistoricalData: NO,
    nowShowingTab: null,

    init: function() {
        var fromDate = this.get('selectedChartFrom').advance({minute: -10});
        if (fromDate) {
            this.set('selectedChartFrom', fromDate);
        }
        this.generateChartStrings();
    },

    nowShowingTabChange: function() {
        SC.Logger.log('TAB CHANGED TO: ' + this.get('nowShowingTab'));
        if (this.get('nowShowingTab') === 'EurekaJView.HistoricalStatisticsOptionsView') {
            this.set('showHistoricalData', YES);
        } else if (this.get('nowShowingTab') === 'EurekaJView.LiveStatisticsOptionsView') {
            this.set('showHistoricalData', NO);
        }

        this.refreshData();
    }.observes('nowShowingTab'),

    orderBy: 'name',

    observeChartFromChange: function() {
        var parsedDate = SC.DateTime.parse(this.get('selectedChartFromString'), this.get('dateFormat'));
        SC.Logger.log('From Date parsed to: ' + parsedDate.get('milliseconds') + ' alreadyselectedDate: ' + this.get('selectedChartFrom').get('milliseconds'));
        if (parsedDate && parsedDate.get('milliseconds') <= this.get('selectedChartTo').get('milliseconds')) {
            this.set('selectedChartFrom', parsedDate);
            //this.refreshData();
        } else {
            this.generateChartStrings();
        }
    }.observes('selectedChartFromString'),

    observeChartToChange: function() {
        var parsedDate =  SC.DateTime.parse(this.get('selectedChartToString'), this.get('dateFormat'));
        SC.Logger.log('To Date parsed to: ' + parsedDate);
        if (parsedDate && parsedDate.get('milliseconds') >= this.get('selectedChartFrom').get('milliseconds')) {
            this.set('selectedChartTo', parsedDate);
            //this.refreshData();
        } else {
            this.generateChartStrings();
        }
    }.observes('selectedChartToString'),

    generateChartStrings: function() {
        this.set('selectedChartFromString', this.generateChartString(this.get('selectedChartFrom')));
        this.set('selectedChartToString', this.generateChartString(this.get('selectedChartTo')));
    },

    selectedChartFromMsProperty: function() {
        this.get('selectedChartFrom').get('milliseconds');
    }.property(),

    selectedChartToMsProperty: function() {
        this.get('selectedChartTo').get('milliseconds');
    }.property(),

    generateChartString: function(date) {
        var fmt = this.get('dateFormat') || '%m/%d/%Y';
        var dateString = date ? date.toFormattedString(fmt) : "";
        return dateString;
    },

    refreshData: function() {
        if (this.get('content')) {
            this.get('content').forEach(function(item, index, enumerable) {
{'fraction_non_alphanumeric': 0.18586071751582756, 'fraction_numerical': 0.0030147723846849564, 'mean_word_length': 3.3969516235917827, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '932408', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1781, 'n_words': 301}