<commit_before>import React from 'react';
import DateDropdown from './date-dropdown.jsx';
import * as Routes from 'violation/src/routes';
import FilterDropdown from './filter-dropdown.jsx';
import ViolationViz from 'violation/src/violation-viz.jsx';
import {stringifySearchParams, values} from 'violation/src/util';

const SHOW_RESOLVED = 'Show resolved',
      SHOW_UNRESOLVED = 'Show unresolved';

class ViolationFilters extends React.Component {
    constructor() {
        super();
    }

    onUpdate(what, data) {
        let params = stringifySearchParams(this.props.params);
        if (what === 'account') {
            // reverse lookup name => id
            const {accounts} = this.props;
            const accountIdsByName = Object.keys(accounts)
                                        .map(id => [accounts[id].name, id])
                                        .reduce((m, a) => {m[a[0]] = a[1]; return m;}, {});
            params.accounts = data.map(name => accountIdsByName[name]);
            params.page = 0;
            this.context.router.push(Routes.violation(params));
            if (this.props.onUpdate) {
                this.props.onUpdate();
            }
        } else if (what === 'date') {
            if (data[1]) {
                params.from = data[0].toISOString();
                params.to = data[1].toISOString();
                params.page = 0;
                this.context.router.push(Routes.violation(params));
                if (this.props.onUpdate) {
                    this.props.onUpdate();
                }
            }
        } else if (what === 'priority') {
            if (data.length === 0) {
                delete params.priority;
            } else {
                params.priority = parseInt(data[0], 10);
            }
            params.page = 0;
            this.context.router.push(Routes.violation(params));
            if (this.props.onUpdate) {
                this.props.onUpdate();
            }
        } else if (what === 'type') {
            if (data.length === 0) {
                delete params.type;
            } else {
                params.type = data[0].replace(/\W/gi, '_');
            }
            params.page = 0;<commit_msg>#487 date picker in violations screen was broken due to version update of date picker component<commit_after>import React from 'react';
import DateDropdown from './date-dropdown.jsx';
import * as Routes from 'violation/src/routes';
import FilterDropdown from './filter-dropdown.jsx';
import ViolationViz from 'violation/src/violation-viz.jsx';
import {stringifySearchParams, values} from 'violation/src/util';

const SHOW_RESOLVED = 'Show resolved',
      SHOW_UNRESOLVED = 'Show unresolved';

class ViolationFilters extends React.Component {
    constructor() {
        super();
    }

    onUpdate(what, data) {
        let params = stringifySearchParams(this.props.params);
        if (what === 'account') {
            // reverse lookup name => id
            const {accounts} = this.props;
            const accountIdsByName = Object.keys(accounts)
                                        .map(id => [accounts[id].name, id])
                                        .reduce((m, a) => {m[a[0]] = a[1]; return m;}, {});
            params.accounts = data.map(name => accountIdsByName[name]);
            params.page = 0;
            this.context.router.push(Routes.violation(params));
            if (this.props.onUpdate) {
                this.props.onUpdate();
            }
        } else if (what === 'date') {
            if (data[1]) {
                params.from = data[0].dateMoment.toISOString();
                params.to = data[1].dateMoment.toISOString();
                params.page = 0;
                this.context.router.push(Routes.violation(params));
                if (this.props.onUpdate) {
                    this.props.onUpdate();
                }
            }
        } else if (what === 'priority') {
            if (data.length === 0) {
                delete params.priority;
            } else {
                params.priority = parseInt(data[0], 10);
            }
            params.page = 0;
            this.context.router.push(Routes.violation(params));
            if (this.props.onUpdate) {
                this.props.onUpdate();
            }
        } else if (what === 'type') {
            if (data.length === 0) {
                delete params.type;
            } else {
                params.type = data[0].replace(/\W/gi, '_');
            }
            params.page = 0;
{'fraction_non_alphanumeric': 0.1329951477723864, 'fraction_numerical': 0.007278341420379356, 'mean_word_length': 1.603329506314581, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6342446', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1237, 'n_words': 262}