<commit_before># encoding: UTF-8

module OrganizationUsersHelper
  def load_organization
    @organization = Organization.where(name: params[:name]).first
    if @organization.nil?
      render_jsonp({}, 401) # Not giving clues to guessers via 404
      return false
    end
  end

  def owners_only
    unless current_viewer_is_owner?
      render_jsonp({}, 401)
      return false
    end
  end

  def load_user
    @user = ::User.where(username: params[:u_username], organization: @organization).first

    if @user.nil?
      render_jsonp("No user with username '#{params[:u_username]}' in '#{@organization.name}'", 404)
      return false
    end
  end
<commit_msg>make load_organization work with names or id<commit_after># encoding: UTF-8
require_dependency 'carto/uuidhelper'

module OrganizationUsersHelper
  def load_organization
    id_or_name = params[:id_or_name]

    @organization = if is_uuid?(id_or_name)
                      Carto::Organization.where(id: id_or_name).first
                    else
                      Carto::Organization.where(name: id_or_name).first
                    end

    unless @organization
      render_jsonp({}, 401) # Not giving clues to guessers via 404
      return false
    end
  end

  def owners_only
    unless current_viewer_is_owner?
      render_jsonp({}, 401)
      return false
    end
  end

  def load_user
    @user = ::User.where(username: params[:u_username], organization: @organization).first

    if @user.nil?
      render_jsonp("No user with username '#{params[:u_username]}' in '#{@organization.name}'", 404)
      return false
    end
  end

{'fraction_non_alphanumeric': 0.09405940594059406, 'fraction_numerical': 0.01608910891089109, 'mean_word_length': 2.924757281553398, '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': '2259044', 'n_tokens_mistral': 523, 'n_tokens_neox': 471, 'n_words': 128}