<commit_before><?php
/**
 * @file
 * Defines a Page callback for Agenda search results.
 */

use \CultuurNet\Search\Parameter;
use \CultuurNet\Search\Component\Facet;

/**
 * Class CultureFeedAgendaPage
 */
class CultureFeedAgendaPage extends CultureFeedSearchPage
    implements CultureFeedSearchPageInterface {

  /**
   * Initializes the search with data from the URL query parameters.
   */
  public function initialize() {

    // Only initialize once.
    if (empty($this->facetComponent)) {
      $this->facetComponent = new Facet\FacetComponent();

      // Retrieve search parameters and add some defaults.
      $params = drupal_get_query_parameters();
      $params += array(
        'sort' => $this->getDefaultSort(),
        'search' => '',
        'facet' => array(),
      );

      $this->pageNumber = empty($params['page']) ? 1 : $params['page'] + 1;

      if (!empty($params['search'])) {
        $this->addQueryTerm($params['search']);
      }

      $this->addFacetFilters($params);
      $this->addSort($params);

      $this->parameters[] = new Parameter\FilterQuery('type:event OR type:production');
      $this->parameters[] = $this->facetComponent->facetField('category');
      $this->parameters[] = $this->facetComponent->facetField('datetype');
      $this->parameters[] = $this->facetComponent->facetField('city');

      $this->execute($params);

      // Warm up cache.
      $this->warmupCache();
    }
  }

  /**
   * Add the sorting parameters for the agenda searches.
   */
  protected function addSort($params) {

    switch ($params['sort']) {

      case 'date':
        $this->parameters[] = new Parameter\Sort('startdate', Parameter\Sort::DIRECTION_ASC);
        break;

      case 'agefrom':
        $this->parameters[] = new Parameter\Sort('agefrom', Parameter\Sort::DIRECTION_ASC);
      break;

      case 'recommend_count':
        $this->parameters[] = new Parameter\Sort('recommend_count', Parameter\Sort::DIRECTION_DESC);
      break;
      
      case 'review_count':
        $this->parameters[] = new Parameter\Sort('review_count', Parameter\Sort::DIRECTION_DESC);
      break;

      case 'comment_count':<commit_msg>CF-297 temp fix<commit_after><?php
/**
 * @file
 * Defines a Page callback for Agenda search results.
 */

use \CultuurNet\Search\Parameter;
use \CultuurNet\Search\Component\Facet;

/**
 * Class CultureFeedAgendaPage
 */
class CultureFeedAgendaPage extends CultureFeedSearchPage
    implements CultureFeedSearchPageInterface {

  /**
   * Initializes the search with data from the URL query parameters.
   */
  public function initialize() {

    // Only initialize once.
    if (empty($this->facetComponent)) {
      $this->facetComponent = new Facet\FacetComponent();

      // Retrieve search parameters and add some defaults.
      $params = drupal_get_query_parameters();
      $params += array(
        'sort' => $this->getDefaultSort(),
        'search' => '',
        'facet' => array(),
      );

      $this->pageNumber = empty($params['page']) ? 1 : $params['page'] + 1;

      if (!empty($params['search'])) {
        $this->addQueryTerm($params['search']);
      }

      $this->addFacetFilters($params);
      $this->addSort($params);

      $this->parameters[] = new Parameter\FilterQuery('type:event OR type:production');
      $this->parameters[] = $this->facetComponent->facetField('category');
      $this->parameters[] = $this->facetComponent->facetField('datetype');
      $this->parameters[] = $this->facetComponent->facetField('city');

      $this->execute($params);

      // Warm up cache.
      $this->warmupCache();
    }
  }

  /**
   * Add the sorting parameters for the agenda searches.
   */
  protected function addSort($params) {

    switch ($params['sort']) {

      case 'date':
        $this->parameters[] = new Parameter\Sort('permanent asc,startdateday asc,weight', Parameter\Sort::DIRECTION_DESC);
      break;

      case 'agefrom':
        $this->parameters[] = new Parameter\Sort('agefrom', Parameter\Sort::DIRECTION_ASC);
      break;

      case 'recommend_count':
        $this->parameters[] = new Parameter\Sort('recommend_count', Parameter\Sort::DIRECTION_DESC);
      break;
      
      case 'review_count':
        $this->parameters[] = new Parameter\Sort('review_count', Parameter\Sort::DIRECTION_DESC);
      break;

      case 'comment_count':
{'fraction_non_alphanumeric': 0.15456835356079687, 'fraction_numerical': 0.0016029310739638196, 'mean_word_length': 3.144212523719165, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, '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': '523710', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1249, 'n_words': 259}