<commit_before>import React, {Component} from 'react';
import { connect} from 'react-redux';
import Dimensions from 'react-dimensions';
import SkyLight from 'react-skylight';
import SketchPicker from 'react-color';
import * as d3 from 'd3';
import { map, clone, groupBy, reduce, forEach, difference, find, uniq, remove, each, includes, assign, isEqual } from 'lodash';
import moment from 'moment';
import { nodesSelect, highlightNodes, nodeSelect } from '../../modules/graph/index';
import { normalize, fieldLocator } from '../../helpers/index';
import { Icon } from '../../components/index';
import { deleteSearch, setDisplayNodes, searchRequest } from '../../modules/search/index';
import Url from "../../domain/Url";
import Tooltip from 'rc-tooltip';

class Queries extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            editSearchValue: null
        };
    }

    componentDidMount() {
    }

    handleEditQuery(query) {
        this.setState({editSearchValue: query});

        this.refs.editDialog.show();
    }

    handleCancelEditQuery() {
        this.setState({editSearchValue: null});
    }

    handleDeleteQuery(query) {
        const { dispatch } = this.props;

        dispatch(deleteSearch({search: query}));
        Url.removeQueryParam('search', query.q);
    }

    handleSearchMore(query) {
        const { dispatch, fields, activeIndices } = this.props;

        dispatch(searchRequest({
            query: query.q,
            fields: fields,
            datasources: activeIndices,
            size: 500
        }));
    }

    handleDisplayMore(query) {
        const { dispatch } = this.props;

        dispatch(setDisplayNodes(query.q, query.displayNodes + 100));
    }

    handleDisplayLess(query) {
        const { dispatch } = this.props;

        dispatch(setDisplayNodes(query.q, query.displayNodes - 100));
    }

    handleChangeQueryColorComplete(color) {
        const search = this.state.editSearchValue;

        search.color = color.hex;

        this.setState({editSearchValue: search});
    }

    countNodesForQuery(query) {
        const { nodes } = this.props;
<commit_msg>fix show less/more nodes<commit_after>import React, {Component} from 'react';
import { connect} from 'react-redux';
import Dimensions from 'react-dimensions';
import SkyLight from 'react-skylight';
import SketchPicker from 'react-color';
import * as d3 from 'd3';
import { map, clone, groupBy, reduce, forEach, difference, find, uniq, remove, each, includes, assign, isEqual } from 'lodash';
import moment from 'moment';
import { nodesSelect, highlightNodes, nodeSelect } from '../../modules/graph/index';
import { normalize, fieldLocator } from '../../helpers/index';
import { Icon } from '../../components/index';
import { deleteSearch, setDisplayNodes, searchRequest } from '../../modules/search/index';
import Url from "../../domain/Url";
import Tooltip from 'rc-tooltip';

class Queries extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            editSearchValue: null
        };
    }

    componentDidMount() {
    }

    handleEditQuery(query) {
        this.setState({editSearchValue: query});

        this.refs.editDialog.show();
    }

    handleCancelEditQuery() {
        this.setState({editSearchValue: null});
    }

    handleDeleteQuery(query) {
        const { dispatch } = this.props;

        dispatch(deleteSearch({search: query}));
        Url.removeQueryParam('search', query.q);
    }

    handleSearchMore(query) {
        const { dispatch, fields, activeIndices } = this.props;

        dispatch(searchRequest({
            query: query.q,
            fields: fields,
            datasources: activeIndices,
            size: 500
        }));
    }

    handleDisplayMore(query) {
        const { dispatch } = this.props;
        const nodes = this.countNodesForQuery(query.q);
        const newNumber = query.displayNodes + 100;

        if (newNumber > Math.ceil(nodes / 100) * 100) {
            return;
        }

        dispatch(setDisplayNodes(query.q, newNumber));
    }

    handleDisplayLess(query) {
        const { dispatch } = this.props;
        const displayNodes = this.countDisplayNodesForQuery(query.q);
        let newNumber = query.displayNodes - 100;

        if (displayNodes < newNumber) {
            newNumber = Math.floor(displayNodes/ 100) * 100;
        }

        if (newNumber < 0) {
            return;
        }

        dispatch(setDisplayNodes(query.q, newNumber));
    }

    handleChangeQueryColorComplete(color) {
        const search = this.state.editSearchValue;

        search.color = color.hex;

        this.setState({editSearchValue: search});
    }

    countNodesForQuery(query) {
        const { nodes } = this.props;

{'fraction_non_alphanumeric': 0.12629829663481512, 'fraction_numerical': 0.007270461154964687, 'mean_word_length': 2.614864864864865, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6629455', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1329, 'n_words': 314}