<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import _ from 'lodash';
import { connect } from 'react-redux';
import UIOptionsComponent from '../components/UIOptionsComponent';
import { changeSelectedMeters, changeSelectedGroups, changeBarDuration, changeChartToRender, changeBarStacking } from '../actions/graph';
import { fetchMetersDetailsIfNeeded } from '../actions/meters';
import { fetchGroupsDetailsIfNeeded } from '../actions/groups';

/**
 * @param {State} state
 * @return {{meterInfo: *, selectedMeters: Array}}
 */
function mapStateToProps(state) {
	const sortedMeters = _.sortBy(_.values(state.meters.byMeterID).map(meter => ({ id: meter.id, name: meter.name.trim() })), 'name');
	const sortedGroups = _.sortBy(_.values(state.groups.byGroupID).map(group => ({ id: group.id, name: group.name.trim() })), 'name');
	return {
		meters: sortedMeters,
		groups: sortedGroups,
		selectedGroups: state.graph.selectedGroups,
		selectedMeters: state.graph.selectedMeters,
		chartToRender: state.graph.chartToRender
	};
}

function mapDispatchToProps(dispatch) {<commit_msg>Fix bug where datasource IDs were passed as prop without type information<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import _ from 'lodash';
import { connect } from 'react-redux';
import UIOptionsComponent from '../components/UIOptionsComponent';
import { changeSelectedMeters, changeSelectedGroups, changeBarDuration, changeChartToRender, changeBarStacking } from '../actions/graph';
import { fetchMetersDetailsIfNeeded } from '../actions/meters';
import { fetchGroupsDetailsIfNeeded } from '../actions/groups';
import { DATA_TYPE_GROUP, DATA_TYPE_METER } from '../utils/Datasources';

/**
 * @param {State} state
 * @return {{meterInfo: *, selectedMeters: Array}}
 */
function mapStateToProps(state) {
	const sortedMeters = _.sortBy(_.values(state.meters.byMeterID).map(meter => ({ id: meter.id, name: meter.name.trim() })), 'name');
	const sortedGroups = _.sortBy(_.values(state.groups.byGroupID).map(group => ({ id: group.id, name: group.name.trim() })), 'name');
	return {
		meters: sortedMeters,
		groups: sortedGroups,
		selectedGroups: state.graph.selectedGroups.map(groupID => (
			{
				label: state.groups.byGroupID[groupID].name,
				type: DATA_TYPE_GROUP,
				value: groupID
			}
		)),
		selectedMeters: state.graph.selectedMeters.map(meterID => (
			{
				label: state.meters.byMeterID[meterID].name,
				type: DATA_TYPE_METER,
				value: meterID
			}
		)),
		chartToRender: state.graph.chartToRender
	};
}

function mapDispatchToProps(dispatch) {
{'fraction_non_alphanumeric': 0.1371666089366124, 'fraction_numerical': 0.0027710426047800486, 'mean_word_length': 4.741550695825049, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7051600', 'n_tokens_mistral': 936, 'n_tokens_neox': 883, 'n_words': 228}