<commit_before>class UserSerializer
  include RestPack::Serializer
  attributes :id, :login, :display_name, :credited_name, :email, :created_at, :updated_at
  can_include :projects, :collections, :classifications, :subjects, :project_preferences

  can_filter_by :login

  def credited_name
    @model.credited_name if permitted_requester?
  end

  def email
    @model.email if permitted_requester?
  end

  private
  
  def permitted_requester?
    @context[:include_private] || 
    (@context[:requester].logged_in? &&
      (@model.id == @context[:requester].id) ||
      @context[:requester].is_admin?)
  end
end<commit_msg>Memoize user serializer permission check<commit_after>class UserSerializer
  include RestPack::Serializer
  attributes :id, :login, :display_name, :credited_name, :email, :created_at, :updated_at
  can_include :projects, :collections, :classifications, :subjects, :project_preferences

  can_filter_by :login

  def credited_name
    @model.credited_name if permitted_requester?
  end

  def email
    @model.email if permitted_requester?
  end

  private
  
  def permitted_requester?
    @perrmitted ||= @context[:include_private] || 
                    (@context[:requester].logged_in? &&
                     (@model.id == @context[:requester].id) ||
                     @context[:requester].is_admin?)
  end
end
{'fraction_non_alphanumeric': 0.10690423162583519, 'fraction_numerical': 0.0, 'mean_word_length': 3.974169741697417, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2995211', 'n_tokens_mistral': 423, 'n_tokens_neox': 407, 'n_words': 88}