<commit_before>import React from 'react';
import Genres from './model/Genres'
import BooksList from './BooksList';
import {BookCheckers} from './model/Books'
import {Form, FormGroup, FormControl, Checkbox} from 'react-bootstrap'


export default React.createClass({

	getInitialState: function () {
		return {
			filters: {}
		}
	},

	filterAuthorGender: function(book) {
		return book.author.gender === this.state.filters.filterAuthorGender;
	} ,
	filterAuthorName: function(book) {
		return book.author.name.indexOf(this.state.filters.filterAuthorName) !== -1;
	},
	filterBookGenre: function(book) {
		return book.genre === this.state.filters.filterBookGenre;
	},
	filterBookType: function(book) {
		return BookCheckers[this.state.filters.filterBookType](book)
	},

	updateFilter: function(name, value) {
		var filters = JSON.parse(JSON.stringify(this.state.filters));
		filters[name] = value;
		this.setState({filters});
	},


	render: function () {

		const filteredBooks = this._isFilterEnabled()
			? this.props.books.filter(this._filterBook)
			: this.props.books;

		return (
			<div>
				<Form inline>
					<FormGroup>
						<FormControl
							type="text"
							data-name="filterAuthorName"
							value={this.state.authorName}
							placeholder="Author name"
							onChange={e => this.updateFilter(e.target.dataset.name, e.target.value)}/>
						<FormControl
							componentClass="select"
							data-name="filterAuthorGender"
							onChange={e => this.updateFilter(e.target.dataset.name, e.target.value)}>
							<option value="">Author gender</option>
							<option value="Male">Male</option>
							<option value="Female">Female</option>
						</FormControl>
						<FormControl
							componentClass="select"
							data-name="filterBookGenre"
							onChange={e => this.updateFilter(e.target.dataset.name, e.target.value)}>
							<option value="">Book genre</option>
							{Genres.sort().map(function (genre, i) {
								return <option key={i} value={genre}>{genre}</option>
							})}
						</FormControl>
						<FormControl
							componentClass="select"
							data-name="filterBookType"
							onChange={e => this.updateFilter(e.target.dataset.name, e.target.value)}><commit_msg>debounce on filter values inserting<commit_after>import React from 'react';
import _ from 'lodash';
import Genres from './model/Genres'
import BooksList from './BooksList';
import {BookCheckers} from './model/Books'
import {Form, FormGroup, FormControl} from 'react-bootstrap'


export default React.createClass({

	componentWillMount: function() {
		this.updateFilter = _.debounce(this.updateFilter, 500);
	},

	getInitialState: function () {
		return {
			filters: {}
		}
	},

	filterAuthorGender: function(book) {
		return book.author.gender === this.state.filters.filterAuthorGender;
	} ,
	filterAuthorName: function(book) {
		return book.author.name.indexOf(this.state.filters.filterAuthorName) !== -1;
	},
	filterBookGenre: function(book) {
		return book.genre === this.state.filters.filterBookGenre;
	},
	filterBookType: function(book) {
		return BookCheckers[this.state.filters.filterBookType](book)
	},

	updateFilter: function(name, value) {
		var filters = JSON.parse(JSON.stringify(this.state.filters));
		filters[name] = value;
		this.setState({filters});
	},

	render: function () {

		const filteredBooks = this._isFilterEnabled()
			? this.props.books.filter(this._filterBook)
			: this.props.books;


		return (
			<div>
				{this.state.updating}
				<Form inline>
					<FormGroup>
						<FormControl
							type="text"
							data-name="filterAuthorName"
							value={this.state.authorName}
							placeholder="Author name"
							onChange={e => this.updateFilter(e.target.dataset.name, e.target.value)}/>
						<FormControl
							componentClass="select"
							data-name="filterAuthorGender"
							onChange={e => this.updateFilter(e.target.dataset.name, e.target.value)}>
							<option value="">Author gender</option>
							<option value="Male">Male</option>
							<option value="Female">Female</option>
						</FormControl>
						<FormControl
							componentClass="select"
							data-name="filterBookGenre"
							onChange={e => this.updateFilter(e.target.dataset.name, e.target.value)}>
							<option value="">Book genre</option>
							{Genres.sort().map(function (genre, i) {
								return <option key={i} value={genre}>{genre}</option>
							})}
						</FormControl>

						<FormControl
							componentClass="select"
							data-name="filterBookType"
							onChange={e => this.updateFilter(e.target.dataset.name, e.target.value)}>
{'fraction_non_alphanumeric': 0.14604285089637078, 'fraction_numerical': 0.0010931351114997813, 'mean_word_length': 3.621212121212121, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 49, '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': '7349194', 'n_tokens_mistral': 1811, 'n_tokens_neox': 1391, 'n_words': 243}