<commit_before>import React from 'react';
import { Mutation } from 'react-apollo';
import IconButton from '@material-ui/core/IconButton';
import PlayArrow from '@material-ui/icons/PlayArrow';
import Snackbar from '@material-ui/core/Snackbar';


class ExecuteRowButton extends React.Component {
    constructor() {
        super();
        this.state = {
            'open': false
        };
    }

    handleSnackbarClose = () => this.setState({ 'open': false });

    execute = (func) => {
        func();
        this.setState({ 'open': true });
    }

    render() {
        return (<Mutation
            mutation={this.props.parameter.repository.execute()}
            variables={{ 'id': this.props.recordId }}>
            {(executeFunc, params) => {
                const { loading, error, called, data } = params;
                if (loading) {
                    return <p>Loading...</p>;
                } else if (called && data) {
                    const responseData = data['executeBatch']['batch'];
                    if (responseData.id !== this.state.currentBatchId) {
                        this.setState({
                            'message': `Batch ${responseData.id}: ${responseData.status}`,
                            'currentBatchId': responseData.id
                        });
                    }
                } else if (error) {
                    return <p>Error...</p>;
                }

                return (
                    <div>
                        <Snackbar
                            anchorOrigin={{
                                vertical: 'bottom',
                                horizontal: 'left',
                            }}
                            open={this.state.open}
                            autoHideDuration={5000}
                            message={<span>{this.state.message}</span>}
                            onClose={this.handleSnackbarClose}>
                        </Snackbar>
                        <IconButton key={`execute_${this.props.recordId}`} onClick={() => this.execute(executeFunc)} color="primary">
                            <PlayArrow />
                        </IconButton>
                    </div>
                );
            }}
        </Mutation>);
    }
}


export default function createExecuteRowButton(button, recordId) {
    return <ExecuteRowButton
        key={`execute_${recordId}`}
        parameter={button.parameter}
        recordId={recordId}>
    </ExecuteRowButton>;
}
<commit_msg>simplify if-branch<commit_after>import React from 'react';
import { Mutation } from 'react-apollo';
import IconButton from '@material-ui/core/IconButton';
import PlayArrow from '@material-ui/icons/PlayArrow';
import Snackbar from '@material-ui/core/Snackbar';


class ExecuteRowButton extends React.Component {
    constructor() {
        super();
        this.state = {
            'open': false
        };
    }

    handleSnackbarClose = () => this.setState({ 'open': false });

    execute = (func) => {
        func();
        this.setState({ 'open': true });
    }

    render() {
        return (<Mutation
            mutation={this.props.parameter.repository.execute()}
            variables={{ 'id': this.props.recordId }}>
            {(executeFunc, params) => {
                const { loading, error, called, data } = params;
                if (loading) {
                    return <p>Loading...</p>;
                }
                if (error) {
                    return <p>Error...</p>;
                }
                if (called && data) {
                    const responseData = data['executeBatch']['batch'];
                    if (responseData.id !== this.state.currentBatchId) {
                        this.setState({
                            'message': `Batch ${responseData.id}: ${responseData.status}`,
                            'currentBatchId': responseData.id
                        });
                    }
                } else if (error) {
                    return <p>Error...</p>;
                }

                return (
                    <div>
                        <Snackbar
                            anchorOrigin={{
                                vertical: 'bottom',
                                horizontal: 'left',
                            }}
                            open={this.state.open}
                            autoHideDuration={5000}
                            message={<span>{this.state.message}</span>}
                            onClose={this.handleSnackbarClose}>
                        </Snackbar>
                        <IconButton key={`execute_${this.props.recordId}`} onClick={() => this.execute(executeFunc)} color="primary">
                            <PlayArrow />
                        </IconButton>
                    </div>
                );
            }}
        </Mutation>);
    }
}


export default function createExecuteRowButton(button, recordId) {
    return <ExecuteRowButton
        key={`execute_${recordId}`}
        parameter={button.parameter}
        recordId={recordId}>
    </ExecuteRowButton>;
}

{'fraction_non_alphanumeric': 0.12546269238262225, 'fraction_numerical': 0.0015585427625170465, 'mean_word_length': 1.2399650959860384, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 47, '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': '1791342', 'n_tokens_mistral': 1259, 'n_tokens_neox': 1216, 'n_words': 230}