<commit_before>module GobiertoPeople
  class PersonDecorator < BaseDecorator
    def initialize(person)
      @object = person
    end

    def contact_email
      person_contact_method_for("Email", "service_url")
    end

    def twitter_handle
      person_contact_method_for("Twitter", "service_handle")
    end

    def twitter_url
      person_contact_method_for("Twitter", "service_url")
    end

    def facebook_handle
      person_contact_method_for("Facebook", "service_handle")
    end

    def facebook_url
      person_contact_method_for("Facebook", "service_url")
    end

    def linkedin_handle
      person_contact_method_for("LinkedIn", "service_handle")
    end

    def linkedin_url
      person_contact_method_for("LinkedIn", "service_url")
    end

    private

    def person_contact_method_for(service_name, attribute_name)
      person_contact_methods.detect do |contact_method|
        contact_method["service_name"] == service_name
      end.try(:[], attribute_name)
    end

    protected

    def person_contact_methods
      @person_contact_methods ||= begin
        object
          .content_blocks
          .find_by("title->'en' = ?", "Contact methods")
          .records
          .pluck(:payload)
      end
    end
  end
end
<commit_msg>Search content block by spanish name<commit_after>module GobiertoPeople
  class PersonDecorator < BaseDecorator
    def initialize(person)
      @object = person
    end

    def contact_email
      person_contact_method_for("Email", "service_url")
    end

    def twitter_handle
      person_contact_method_for("Twitter", "service_handle")
    end

    def twitter_url
      person_contact_method_for("Twitter", "service_url")
    end

    def facebook_handle
      person_contact_method_for("Facebook", "service_handle")
    end

    def facebook_url
      person_contact_method_for("Facebook", "service_url")
    end

    def linkedin_handle
      person_contact_method_for("LinkedIn", "service_handle")
    end

    def linkedin_url
      person_contact_method_for("LinkedIn", "service_url")
    end

    private

    def person_contact_method_for(service_name, attribute_name)
      person_contact_methods.detect do |contact_method|
        contact_method["service_name"] == service_name
      end.try(:[], attribute_name)
    end

    protected

    def person_contact_methods
      @person_contact_methods ||= begin
        object
          .content_blocks
          .find_by("title->'es' = ?", "Formas de contacto")
          .records
          .pluck(:payload)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.07776049766718507, 'fraction_numerical': 0.0, 'mean_word_length': 3.014040561622465, 'pattern_counts': {'":': 0, '<': 5, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2135029', 'n_tokens_mistral': 780, 'n_tokens_neox': 743, 'n_words': 152}