<commit_before>class SearchesController < ApplicationController

  protect_from_forgery except: :show

  def show
    search_query = params[:search_string]
    search_array = search_query.split(" ")
    search_array.concat(search_array.map{|str| str.downcase})
    search_array.concat(search_array.map{|str| str.upcase})
    search_array.concat(search_array.map{|str| str.capitalize})
    @search_return = []
    if params[:search_type] == "Films"
      search_array.each do |search_string|
        @search_return.concat(Film.all.find_all {|film| film.title.include?(search_string)})
        @search_return.concat(Film.all.find_all {|film| film.description.include?(search_string)})
        @search_return.concat(Film.all.find_all {|film| film.release_year.to_s.include?(search_string)})
      end
    else
      search_array.each do |search_string|
        @search_return.concat(Review.all.find_all {|review| review.headline.include?(search_string)})
        @search_return.concat(Review.all.find_all {|review| review.content.include?(search_string)})
        @search_return.concat(Review.all.find_all {|review| review.reviewer.username.include?(search_string)})
      end
    end
    @search_return
  end

end<commit_msg>Only return unique objects<commit_after>class SearchesController < ApplicationController

  protect_from_forgery except: :show

  def show
    search_query = params[:search_string]
    search_array = search_query.split(" ")
    search_array.concat(search_array.map{|str| str.downcase})
    search_array.concat(search_array.map{|str| str.upcase})
    search_array.concat(search_array.map{|str| str.capitalize})
    search_array = search_array.uniq
    @search_return = []
    if params[:search_type] == "Films"
      search_array.each do |search_string|
        @search_return.concat(Film.all.find_all {|film| film.title.include?(search_string)})
        @search_return.concat(Film.all.find_all {|film| film.description.include?(search_string)})
        @search_return.concat(Film.all.find_all {|film| film.release_year.to_s.include?(search_string)})
      end
    else
      search_array.each do |search_string|
        @search_return.concat(Review.all.find_all {|review| review.headline.include?(search_string)})
        @search_return.concat(Review.all.find_all {|review| review.content.include?(search_string)})
        @search_return.concat(Review.all.find_all {|review| review.reviewer.username.include?(search_string)})
      end
    end
  @search_return = @search_return.uniq {|obj| obj.id}
  end

end
{'fraction_non_alphanumeric': 0.12485183721849072, 'fraction_numerical': 0.0, 'mean_word_length': 4.456896551724138, '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': '2749705', 'n_tokens_mistral': 826, 'n_tokens_neox': 803, 'n_words': 113}