<commit_before>import React, { Component } from 'react';
import { uniq, find, map, mapValues, reduce } from 'lodash';
import { fieldLocator } from '../../helpers/index';
import { highlightNodes } from '../../modules/graph/index';
import { Icon } from '../../components/index';

export default class Record extends Component {
    constructor(props) {
        super(props);

        this.state = {
        };

        this.handleToggleExpand.bind(this);
    }

    handleToggleExpand(id) {
        const { toggleExpand } = this.props;
        toggleExpand(id);
    }

    render() {
        const { record, columns, node, searches } = this.props;
        const { expanded } = this.props;

        // make queries uniq
        const queries = (record.nodes || []).map((n) => {
            return (uniq(n.queries) || []).map((q) => {
                const search = find(searches, (s) => s.q == q);

                if (!search) {
                    // Maybe the search query was already deleted
                    return (null);
                }

                if (find(search.items, (i) => i.id == record.id)) {
                    return (<Icon name='ion-ios-lightbulb' style={{ color: search.color }} alt={ search.q } />);
                }

                return (null);
            });
        });

        const renderedColumns = (columns || []).map((value) => {
            return (
                <td key={ 'column_' + record.id + value }>
                    <span className={'length-limiter'}>{ fieldLocator(record.fields, value) }</span>
                </td>
            );
        });

        return (
            <tr key={`record_${record.id}`} className={`columns ${expanded ? 'expanded' : 'closed'}`}>
                <td width="25" style={{'textAlign': 'center'}}>
                    <Icon onClick={() => this.handleToggleExpand(record.id) }
                          name={expanded ? 'ion-ios-minus' : 'ion-ios-plus'}/>

                    { queries }
                </td>
                { renderedColumns}
            </tr>
        );
    }
}
<commit_msg>make table not crash on weird data<commit_after>import React, { Component } from 'react';
import { uniq, find, map, mapValues, reduce } from 'lodash';
import { fieldLocator } from '../../helpers/index';
import { highlightNodes } from '../../modules/graph/index';
import { Icon } from '../../components/index';

export default class Record extends Component {
    constructor(props) {
        super(props);

        this.state = {
        };

        this.handleToggleExpand.bind(this);
    }

    handleToggleExpand(id) {
        const { toggleExpand } = this.props;
        toggleExpand(id);
    }

    render() {
        const { record, columns, node, searches } = this.props;
        const { expanded } = this.props;

        // make queries uniq
        const queries = (record.nodes || []).map((n) => {
            return (uniq(n.queries) || []).map((q) => {
                const search = find(searches, (s) => s.q == q);

                if (!search) {
                    // Maybe the search query was already deleted
                    return (null);
                }

                if (find(search.items, (i) => i !== null && i.id === record.id)) {
                    return (<Icon name='ion-ios-lightbulb' style={{ color: search.color }} alt={ search.q } />);
                }

                return (null);
            });
        });

        const renderedColumns = (columns || []).map((value) => {
            return (
                <td key={ 'column_' + record.id + value }>
                    <span className={'length-limiter'}>{ fieldLocator(record.fields, value) }</span>
                </td>
            );
        });

        return (
            <tr key={`record_${record.id}`} className={`columns ${expanded ? 'expanded' : 'closed'}`}>
                <td width="25" style={{'textAlign': 'center'}}>
                    <Icon onClick={() => this.handleToggleExpand(record.id) }
                          name={expanded ? 'ion-ios-minus' : 'ion-ios-plus'}/>

                    { queries }
                </td>
                { renderedColumns}
            </tr>
        );
    }
}

{'fraction_non_alphanumeric': 0.16087577344121848, 'fraction_numerical': 0.0009519276534983341, 'mean_word_length': 1.5643685173886517, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 35, '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': '2744924', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1134, 'n_words': 266}