<commit_before>module Api
  module V1
    class SearchController < ApplicationController
      include NewsHelper

      def search
        title = params[:title]
        content = params[:content]
        startTime = params[:start_time]
        endTime = params[:end_time]

        page = get_page(params[:p])
        start = (page - 1) * News::PAGINATION_STEP

        # query title and content
        news = News.where.not(status: News::STATUS[:deleted])
        title_field = News.arel_table[:title]
        news = news.where(title_field.matches("%#{title}%")) unless title.blank?
        content_field = News.arel_table[:content]<commit_msg>Support search by channel & event<commit_after>module Api
  module V1
    class SearchController < ApplicationController
      include NewsHelper

      def search
        title = params[:title]
        content = params[:content]
        channel = params[:channel]
        event = params[:event]
        startTime = params[:start_time]
        endTime = params[:end_time]

        page = get_page(params[:p])
        start = (page - 1) * News::PAGINATION_STEP

        # query title and content
        news = News.where.not(status: News::STATUS[:deleted])
        news = news.where(channel: channel) unless channel.blank?
        news = news.where(event: event) unless event.blank?
        title_field = News.arel_table[:title]
        news = news.where(title_field.matches("%#{title}%")) unless title.blank?
        content_field = News.arel_table[:content]
{'fraction_non_alphanumeric': 0.10956175298804781, 'fraction_numerical': 0.0026560424966799467, 'mean_word_length': 2.7675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2356070', 'n_tokens_mistral': 419, 'n_tokens_neox': 414, 'n_words': 97}