<commit_before>module GmailApi

  class Label

    def self.find_collection(client, ids)
      calls = ids.reject { |id| id =~ /INBOX|CATEGORY_|STARRED|SENT/ }.map { |id| { api_method: GmailApi.api.users.labels.get, parameters: { id: id, 'userId'=>'me' }  } }
      labels = []
      get_batched_labels(labels)
      labels
    end

    def self.get_batched_labels(labels)
      if labels.any?
        client.execute_batch(calls) do |result|
          labels << Label.new(result)
        end
      end
    end
      
    def self.find(client, id)
      new client.execute(GmailApi.api.users.labels.get, parameters: { id: id })
    end

    def initialize(response)
      @response = response
      @raw      = response && JSON(response.body) || {}
    end

    def name
      @raw['name']
    end

    def id
      @raw['id']
    end

    def type
      @raw['type']
    end


  end
  
end<commit_msg>fix label fetch for messages<commit_after>module GmailApi

  class Label

    def self.all(client, ids)
      calls = ids.reject { |id| id =~ /INBOX|CATEGORY_|STARRED|SENT/ }.map { |id| { api_method: GmailApi.api.users.labels.get, parameters: { id: id, 'userId'=>'me' }  } }
      get_batched_labels(client, calls)
    end

    def self.get_batched_labels(client, calls)
      labels = []
      if calls.any?
        client.execute_batch(calls) do |result|
          labels << Label.new(result)
        end
      end
      labels
    end
      
    def self.find(client, id)
      new client.execute(GmailApi.api.users.labels.get, parameters: { id: id })
    end

    def initialize(response)
      @response = response
      @raw      = response && JSON(response.body) || {}
    end

    def name
      @raw['name']
    end

    def id
      @raw['id']
    end

    def type
      @raw['type']
    end


  end
  
end
{'fraction_non_alphanumeric': 0.12211221122112212, 'fraction_numerical': 0.0, 'mean_word_length': 2.1200686106346485, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6922438', 'n_tokens_mistral': 623, 'n_tokens_neox': 612, 'n_words': 139}