<commit_before>class OrcidUser < Base
  attr_reader :id, :name, :family_name, :given_names, :updated_at

  def initialize(item, options={})
    @id = item.dig("orcid-profile", "orcid-identifier", "path")
    @family_name = item.dig("orcid-profile", "orcid-bio", "personal-details", "family-name", "value")
    @given_names = item.dig("orcid-profile", "orcid-bio", "personal-details", "given-names", "value")
    if item.dig("orcid-bio", "personal-details", "credit-name").present?
      @name = item.dig("orcid-profile", "orcid-bio", "personal-details", "credit-name", "value")
    elsif @given_names.present? || @family_name.present?
      @name = [@given_names, @family_name].join(" ")
    else
      @name = @uid
    end
    @updated_at = Date.today.to_s + "T00:00:00Z"
  end

  def self.get_query_url(options={})
    params = { q: options.fetch(:query, nil),
               rows: options.dig(:page, :size) || 25,
               offset: options.dig(:page, :number) || 0 }.compact
    url + "?" + URI.encode_www_form(params)
  end

  def self.get_data(options={})
    query_url = get_query_url(options)
    Maremma.get(query_url, accept: 'json', bearer: ENV['ORCID_TOKEN'])
  end

  def self.parse_data(result, options={})
    return nil if result.blank? || result.body['errors']

    if options[:id].present?
      item = result.body.dig("data", "orcid-search-results", "orcid-search-result") || []
      return nil unless item.present?
<commit_msg>more specific query for orcid users<commit_after>class OrcidUser < Base
  attr_reader :id, :name, :family_name, :given_names, :updated_at

  def initialize(item, options={})
    @id = item.dig("orcid-profile", "orcid-identifier", "path")
    @family_name = item.dig("orcid-profile", "orcid-bio", "personal-details", "family-name", "value")
    @given_names = item.dig("orcid-profile", "orcid-bio", "personal-details", "given-names", "value")
    if item.dig("orcid-bio", "personal-details", "credit-name").present?
      @name = item.dig("orcid-profile", "orcid-bio", "personal-details", "credit-name", "value")
    elsif @given_names.present? || @family_name.present?
      @name = [@given_names, @family_name].join(" ")
    else
      @name = @uid
    end
    @updated_at = Date.today.to_s + "T00:00:00Z"
  end

  def self.get_query_url(options={})
    query = options.fetch(:query, nil).present? ? "#{options.fetch(:query)}" : nil
    params = { q: query,
               rows: options.dig(:page, :size) || 25,
               offset: options.dig(:page, :number) || 0 }.compact
    url + "?" + URI.encode_www_form(params)
  end

  def self.get_data(options={})
    query_url = get_query_url(options)
    Maremma.get(query_url, accept: 'json', bearer: ENV['ORCID_TOKEN'])
  end

  def self.parse_data(result, options={})
    return nil if result.blank? || result.body['errors']

    if options[:id].present?
      item = result.body.dig("data", "orcid-search-results", "orcid-search-result") || []
      return nil unless item.present?

{'fraction_non_alphanumeric': 0.17938420348058903, 'fraction_numerical': 0.006024096385542169, 'mean_word_length': 3.751987281399046, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2938477', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1023, 'n_words': 205}