<commit_before>'use strict';
import Reflux from 'reflux';
import Socket from 'socket.io-client';
import {filter} from 'lodash';
import QueryAction from './QueryUpdate.action.js';

const socket = Socket.connect();

let FilterActions = Reflux.createAction(
  {children: ["updated", "failed"]
});

function getQueryTextElements (query) {
  return filter(query, element => element.type === 'text')
    .map(element => element.value);
}

QueryAction.listen((query) => {
  socket.emit('getFilterGuidesRequest', getQueryTextElements(query).join(' '));
});

socket.on('getFilterGuidesResponse', (data) => {
  FilterActions.updated(data)
});

export default FilterActions;<commit_msg>Remove filterelements if no query<commit_after>'use strict';
import Reflux from 'reflux';
import Socket from 'socket.io-client';
import {filter} from 'lodash';
import QueryAction from './QueryUpdate.action.js';

const socket = Socket.connect();

let FilterActions = Reflux.createAction({
  children: ["updated", "failed"]
});

function getQueryTextElements(query) {
  return filter(query, element => element.type === 'text')
    .map(element => element.value);
}

QueryAction.listen((query) => {
  if (query.length > 0) {
    let q = getQueryTextElements(query).join(' ');
    socket.emit('getFilterGuidesRequest', q);
  } else {
    FilterActions.updated([]);
  }

});

socket.on('getFilterGuidesResponse', (data) => {
  FilterActions.updated(data)
});

export default FilterActions;
{'fraction_non_alphanumeric': 0.16038382453735436, 'fraction_numerical': 0.0006854009595613434, 'mean_word_length': 5.488888888888889, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '3839549', 'n_tokens_mistral': 451, 'n_tokens_neox': 442, 'n_words': 102}