<commit_before>import { default as React, Component } from 'react';
import Select from 'react-select';
import classNames from 'classnames';
import { manager } from '../middleware/ChannelManager.js';
var helper = require('../middleware/helper.js');

export class MultiDropdownRange extends Component {
	constructor(props, context) {
		super(props);
		this.state = {
			selected: ""
		};
		this.type = 'range';
		this.state.data = this.props.data.map(item => {
			item.value = item.label;
			return item;
		});
		this.defaultSelected = this.props.defaultSelected;
		this.handleChange = this.handleChange.bind(this);
		this.defaultQuery = this.defaultQuery.bind(this);
	}

	// Set query information
	componentDidMount() {
		this.setQueryInfo();
		if(this.defaultSelected) {
			let records = this.state.data.filter((record) => {
				return this.defaultSelected.indexOf(record.label) > -1 ? true : false;
			});
			if(records && records.length) {
				this.handleChange(records);
			}
		}
	}

	componentWillUpdate() {
		setTimeout(() => {
			if (this.defaultSelected != this.props.defaultSelected) {
				this.defaultSelected = this.props.defaultSelected;
				let records = this.state.data.filter((record) => {
					return this.defaultSelected.indexOf(record.label) > -1 ? true : false;
				});
				if(records && records.length) {
					this.handleChange(records);
				}
			}
		}, 300);
	}

	// set the query type and input data
	setQueryInfo() {
		let obj = {
			key: this.props.sensorId,
			value: {
				queryType: this.type,
				inputData: this.props.appbaseField,
				defaultQuery: this.defaultQuery
			}
		};<commit_msg>fix array equality check in multi-dropdown-range sensor<commit_after>import { default as React, Component } from 'react';
import Select from 'react-select';
import classNames from 'classnames';
import { manager } from '../middleware/ChannelManager.js';
var helper = require('../middleware/helper.js');
var _ = require('lodash');

export class MultiDropdownRange extends Component {
	constructor(props, context) {
		super(props);
		this.state = {
			selected: ""
		};
		this.type = 'range';
		this.state.data = this.props.data.map(item => {
			item.value = item.label;
			return item;
		});
		this.defaultSelected = this.props.defaultSelected;
		this.handleChange = this.handleChange.bind(this);
		this.defaultQuery = this.defaultQuery.bind(this);
	}

	// Set query information
	componentDidMount() {
		this.setQueryInfo();
		if(this.defaultSelected) {
			let records = this.state.data.filter((record) => {
				return this.defaultSelected.indexOf(record.label) > -1 ? true : false;
			});
			if(records && records.length) {
				this.handleChange(records);
			}
		}
	}

	componentWillUpdate() {
		setTimeout(() => {
			if (!_.isEqual(this.defaultSelected, this.props.defaultSelected)) {
				this.defaultSelected = this.props.defaultSelected;
				let records = this.state.data.filter((record) => {
					return this.defaultSelected.indexOf(record.label) > -1 ? true : false;
				});
				if(records && records.length) {
					this.handleChange(records);
				}
			}
		}, 300);
	}

	// set the query type and input data
	setQueryInfo() {
		let obj = {
			key: this.props.sensorId,
			value: {
				queryType: this.type,
				inputData: this.props.appbaseField,
				defaultQuery: this.defaultQuery
			}
		};
{'fraction_non_alphanumeric': 0.14337458496830668, 'fraction_numerical': 0.003018412315122246, 'mean_word_length': 3.5459533607681757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '5608078', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1027, 'n_words': 210}