<commit_before>import Ember from 'ember';
import moment from 'moment';
//import { dateRangeFilter } from 'ember-share/utils/elastic-query';

const DATE_FORMAT = 'YYYY-MM-DD';

export default Ember.Component.extend({
    min_date: null,
    max_date: null,
    state: {
        start: '1996-01-01',
        end: (new Date()).toISOString().split('T')[0]
    },
    init() {
        this._super(...arguments);
    },

    didInsertElement() {
        this._super(...arguments);

        let dateRanges = {
            'Past week': [moment().subtract(1, 'week'), moment()],
            'Past month': [moment().subtract(1, 'month'), moment()],
            'Past year': [moment().subtract(1, 'year'), moment()],
            'Past decade': [moment().subtract(10, 'year'), moment()]
        };

        let picker = this.$('.date-range');
        picker.daterangepicker({
            ranges: dateRanges,
            autoUpdateInput: false,
            locale: { cancelLabel: 'Clear' }
        });

        picker.on('apply.daterangepicker', (ev, picker) => {
            Ember.run(() => {
                let start = picker.startDate;
                let end = picker.endDate;
                this.send('transitionToFacet', start, end);
            });
        });

        picker.on('cancel.daterangepicker', () => {
            Ember.run(() => {
                this.send('clear');
            });<commit_msg>Load with existing parameters<commit_after>import Ember from 'ember';
import moment from 'moment';
//import { dateRangeFilter } from 'ember-share/utils/elastic-query';

const DATE_FORMAT = 'YYYY-MM-DD';

export default Ember.Component.extend({
    state: {
        start: null,
        end: null
    },
    init() {
        this._super(...arguments);
        let queryParams = this.get('parameters');
        this.set('state.start', queryParams.start || '1996-01-01')
        this.set('state.end', queryParams.end || (new Date()).toISOString().split('T')[0])
    },

    didInsertElement() {
        this._super(...arguments);

        let dateRanges = {
            'Past week': [moment().subtract(1, 'week'), moment()],
            'Past month': [moment().subtract(1, 'month'), moment()],
            'Past year': [moment().subtract(1, 'year'), moment()],
            'Past decade': [moment().subtract(10, 'year'), moment()]
        };

        let picker = this.$('.date-range');
        picker.daterangepicker({
            ranges: dateRanges,
            autoUpdateInput: false,
            locale: { cancelLabel: 'Clear' }
        });

        picker.on('apply.daterangepicker', (ev, picker) => {
            Ember.run(() => {
                let start = picker.startDate;
                let end = picker.endDate;
                this.send('transitionToFacet', start, end);
            });
        });

        picker.on('cancel.daterangepicker', () => {
            Ember.run(() => {
                this.send('clear');
            });
{'fraction_non_alphanumeric': 0.17345553292600135, 'fraction_numerical': 0.009504412763068567, 'mean_word_length': 1.9858156028368794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '7551990', 'n_tokens_mistral': 889, 'n_tokens_neox': 850, 'n_words': 170}