<commit_before>import React from 'react';
import FalcorController from 'lib/falcor/FalcorController';
import { browserHistory } from 'react-router';
import _ from 'lodash';

// Components
import ArticleList from 'components/main/ArticleList';

// Allows user to navigate to populated search page on pressing 'Enter'
function handleSubmit(e) {
  e.preventDefault();
  browserHistory.push(`/search?q=${e.target.search.value}`);
}

export default class SearchController extends FalcorController {
  static getFalcorPathSets(params, queryParams) {
    // If you just went straight to the search page
    if (!queryParams.q) {
      return [];
    }
    return [
      [
        'search',
        'posts',
        queryParams.q,
        { length: 20 },
        ['title', 'teaser', 'issueNumber', 'slug', 'image_url', 'published_at'],
      ],
      ['search', 'posts', queryParams.q, { length: 20 }, 'category', 'slug'],
      [
        'search',
        'posts',
        queryParams.q,
        { length: 20 },
        'staff',
        { length: 10 },
        ['name', 'slug'],
      ],
    ];
  }

  render() {
    // Render no results found message, empty results or list of found articles
    const renderContent = () => {
      if (!this.props.location.query.q) {
        return null;
      }
      if (!this.state.data || Object.keys(this.state.data).length === 0) {
        return (
          <div className="search__no-data">
            Oops! No Results found. <br /><commit_msg>Fixed bug: Search was not working at ALL<commit_after>import React from 'react';
import FalcorController from 'lib/falcor/FalcorController';
import { browserHistory } from 'react-router';
import _ from 'lodash';

// Components
import ArticleList from 'components/main/ArticleList';

// Allows user to navigate to populated search page on pressing 'Enter'
function handleSubmit(e) {
  e.preventDefault();
  browserHistory.push(`/search?q=${e.target.search.value}`);
}

export default class SearchController extends FalcorController {
  static getFalcorPathSets(params, queryParams) {
    // If you just went straight to the search page
    if (!queryParams.q) {
      return [];
    }
    return [
      [
        'search',
        'articles',
        queryParams.q,
        { length: 20 },
        ['title', 'teaser', 'issueNumber', 'slug', 'image_url', 'published_at'],
      ],
      ['search', 'articles', queryParams.q, { length: 20 }, 'category', 'slug'],
      [
        'search',
        'articles',
        queryParams.q,
        { length: 20 },
        'staff',
        { length: 10 },
        ['name', 'slug'],
      ],
    ];
  }

  render() {
    // Render no results found message, empty results or list of found articles
    const renderContent = () => {
      if (!this.props.location.query.q) {
        return null;
      }
      if (!this.state.data || Object.keys(this.state.data).length === 0) {
        return (
          <div className="search__no-data">
            Oops! No Results found. <br />
{'fraction_non_alphanumeric': 0.14033333333333334, 'fraction_numerical': 0.006, 'mean_word_length': 2.522300469483568, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1070565', 'n_tokens_mistral': 892, 'n_tokens_neox': 873, 'n_words': 239}