<commit_before>module Rlocu
  class VenueSearch
    def initialize(return_fields: [])
      @return_fields = return_fields.empty? ? %w{locu_id name location description menus} : return_fields
      @key_value_conditions = []
    end

    def with_menus
      @key_value_conditions << QueryBuilder::KeyValueCondition.new(key: 'menus', value: true, condition: '$present')
      self
    end

    def in_lat_long_radius(lat:, long:, radius:)
      lat_long_radius = Utilities::LatLongRadius.new(lat: lat, long: long, radius: radius)
      @key_value_conditions << QueryBuilder::KeyValueCondition.new(key: 'location', value: lat_long_radius, condition: '$in_lat_lng_radius')
      self
    end

    def locu_id(locu_id)
      @key_value_conditions << QueryBuilder::KeyValueCondition.new(key: 'locu_id', value: locu_id)
      self
    end

    def categories_in(categories)
      raise ArgumentError unless categories.is_a? Array
      @key_value_conditions << QueryBuilder::KeyValueCondition.new(key: 'categories', value: categories, condition: '$contains_any')
      self
    end

    def search
      conditions = [QueryBuilder::QueryCondition.new(key_value_conditions: key_value_conditions)]
      venue_query = VenueQuery.new(query_conditions: conditions, return_fields: return_fields)
      venue_query.query
    end

    private
    attr_reader :return_fields, :key_value_conditions
  end
end
<commit_msg>VenueSearch<commit_after>module Rlocu
  class VenueSearch
    def initialize(return_fields: [])
      @return_fields = return_fields.empty? ? %w{locu_id name location description menus} : return_fields
      @key_value_conditions = []
    end

    def with_menus
      @key_value_conditions << QueryBuilder::KeyValueCondition.new(key: 'menus', value: true, condition: '$present')
      self
    end

    def in_lat_long_radius(lat:, long:, radius:)
      lat_long_radius = Utilities::LatLongRadius.new(lat: lat, long: long, radius: radius)
      @key_value_conditions << QueryBuilder::KeyValueCondition.new(key: 'location', value: lat_long_radius, condition: '$in_lat_lng_radius')
      self
    end

    def locu_id(locu_id)
      @key_value_conditions << QueryBuilder::KeyValueCondition.new(key: 'locu_id', value: locu_id)
      self
    end

    def in_categories(categories)
      raise ArgumentError unless categories.is_a? Array
      @key_value_conditions << QueryBuilder::KeyValueCondition.new(key: 'categories', value: categories, condition: '$contains_any')
      self
    end

    def search
      conditions = [QueryBuilder::QueryCondition.new(key_value_conditions: key_value_conditions)]
      venue_query = VenueQuery.new(query_conditions: conditions, return_fields: return_fields)
      venue_query.query
    end

    private
    attr_reader :return_fields, :key_value_conditions
  end
end

{'fraction_non_alphanumeric': 0.09388335704125178, 'fraction_numerical': 0.0, 'mean_word_length': 4.2189239332096475, 'pattern_counts': {'":': 0, '<': 19, '<?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': '3679291', 'n_tokens_mistral': 857, 'n_tokens_neox': 840, 'n_words': 180}