<commit_before>module Keener
  class Query
    def initialize(project_id, event_collection, options = {})
      @project_id = project_id
      @event_collection = event_collection
      @options = options
    end
  end

  class Metric < Query
    def add_filter(property, operator, value)
      @options[:filters] ||= []
      @options[:filters] << {
        :property_name => property,
        :operator => operator,
        :property_value => value
      }
      self
    end

    def interval(interval)
      @options[:interval] = interval
      self
    end

    def timeframe(timeframe)
      @options[:timeframe] = timeframe
      self
    end

    def group_by(group_by)
      @options[:group_by] = group_by
      self
    end

    def count
      Keened.count(@project_id, @event_collection, @options).get
    end

    def count_unique(target_property)
      Keened.count_unique(@project_id, @event_collection, target_property, @options).get
    end

    def minimum(target_property)
      Keened.minimum(@project_id, @event_collection, target_property, @options).get
    end

    def maximum(target_property)
      Keened.maximum(@project_id, @event_collection, target_property, @options).get
    end

    def sum(target_property)
      Keened.sum(@project_id, @event_collection, target_property, @options).get
    end

    def average(target_property)
      Keened.average(@project_id, @event_collection, target_property, @options).get
    end
  end

  #TODO implement
  class Funnel < Query

  end

  #TODO implement
  class Step < Query

  end
end<commit_msg>Fixed typo, and allow block argument to Query<commit_after>module Keener
  class Query
    def initialize(project_id, event_collection, options = {})
      @project_id = project_id
      @event_collection = event_collection
      @options = options
      yield self if block_given?
    end
  end

  class Metric < Query
    def add_filter(property, operator, value)
      @options[:filters] ||= []
      @options[:filters] << {
        :property_name => property,
        :operator => operator,
        :property_value => value
      }
      self
    end

    def interval(interval)
      @options[:interval] = interval
      self
    end

    def timeframe(timeframe)
      @options[:timeframe] = timeframe
      self
    end

    def group_by(group_by)
      @options[:group_by] = group_by
      self
    end

    def count
      Keener.count(@project_id, @event_collection, @options).get
    end

    def count_unique(target_property)
      Keener.count_unique(@project_id, @event_collection, target_property, @options).get
    end

    def minimum(target_property)
      Keener.minimum(@project_id, @event_collection, target_property, @options).get
    end

    def maximum(target_property)
      Keener.maximum(@project_id, @event_collection, target_property, @options).get
    end

    def sum(target_property)
      Keener.sum(@project_id, @event_collection, target_property, @options).get
    end

    def average(target_property)
      Keener.average(@project_id, @event_collection, target_property, @options).get
    end
  end

  #TODO implement
  class Funnel < Query

  end

  #TODO implement
  class Step < Query

  end
end
{'fraction_non_alphanumeric': 0.08980355472404115, 'fraction_numerical': 0.0, 'mean_word_length': 2.960493827160494, 'pattern_counts': {'":': 0, '<': 13, '<?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': '7206085', 'n_tokens_mistral': 974, 'n_tokens_neox': 940, 'n_words': 222}