<commit_before>class Repository

  include Tire::Model::Persistence
  include Tire::Model::Search
  include Tire::Model::Callbacks

  validates_presence_of :name, :type, :url, :datasets, :latitude, :longitude

  property :name
  property :type
  property :url
  property :latitude
  property :longitude
  property :datasets

  property :completeness
  property :weighted_completeness
  property :richness_of_information
  property :accuracy
  property :accessibility

  def metadata
    total = Tire.search('metadata', :search_type => 'count') do
      query { all }
    end.results.total

    name = @name
    Tire.search 'metadata' do
      query { string 'repository:' + name }
      size total
    end.results.map { |entry| entry.to_hash }
  end

  def update_score(metric, score)<commit_msg>Add get all metadata with certain field method<commit_after>class Repository

  include Tire::Model::Persistence
  include Tire::Model::Search
  include Tire::Model::Callbacks

  validates_presence_of :name, :type, :url, :datasets, :latitude, :longitude

  property :name
  property :type
  property :url
  property :latitude
  property :longitude
  property :datasets

  property :completeness
  property :weighted_completeness
  property :richness_of_information
  property :accuracy
  property :accessibility

  def metadata
    name = @name
    max = total
    Tire.search 'metadata' do
      query { string 'repository:' + name }
      size max
    end.results.map { |entry| entry.to_hash }
  end

  def total
    name = @name
    total = Tire.search('metadata', :search_type => 'count') do
      query { string 'repository:' + name }
    end.results.total
  end

  def metadata_with_field(field, value="*")
    name = @name
    max = total
    Tire.search 'metadata' do
      query do
        boolean do
          must { string 'repository:' + name }
          must { string field + ":" + value }
        end
      end
      size max
    end.results.map { |entry| entry.to_hash }
  end

  def update_score(metric, score)
{'fraction_non_alphanumeric': 0.09297725024727992, 'fraction_numerical': 0.0, 'mean_word_length': 3.241090146750524, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 5, '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': '1273372', 'n_tokens_mistral': 627, 'n_tokens_neox': 604, 'n_words': 175}