<commit_before>class Api::GithubUsersController < Api::ApplicationController
  before_action :check_api_key, :find_user

  def show
    render json: @github_user.as_json
  end

  def repositories
    @repositories = @github_user.github_repositories.open_source.source.order('stargazers_count DESC')

    paginate json: @repositories
  end

  def projects
    @projects = @github_user.projects.joins(:github_repository).includes(:versions).order('projects.rank DESC, projects.created_at DESC')
    @projects = @projects.keywords(params[:keywords].split(',')) if params[:keywords].present?

    paginate json: @projects
  end

  private

  def find_user
    @github_user = GithubUser.visible.where("lower(login) = ?", params[:login].downcase).first
    @github_user = GithubOrganisation.visible.where("lower(login) = ?", params[:login].downcase).first if @github_user.nil?
    raise ActiveRecord::RecordNotFound if @github_user.nil?
  end
end<commit_msg>include github info in github user projects api response Fixes #628<commit_after>class Api::GithubUsersController < Api::ApplicationController
  before_action :check_api_key, :find_user

  def show
    render json: @github_user.as_json
  end

  def repositories
    @repositories = @github_user.github_repositories.open_source.source.order('stargazers_count DESC')

    paginate json: @repositories
  end

  def projects
    @projects = @github_user.projects.joins(:github_repository).includes(:versions).order('projects.rank DESC, projects.created_at DESC')
    @projects = @projects.keywords(params[:keywords].split(',')) if params[:keywords].present?

    paginate json: @projects.as_json(only: Project::API_FIELDS, methods: [:package_manager_url, :stars, :forks, :keywords], include: {versions: {only: [:number, :published_at]} })
  end

  private

  def find_user
    @github_user = GithubUser.visible.where("lower(login) = ?", params[:login].downcase).first
    @github_user = GithubOrganisation.visible.where("lower(login) = ?", params[:login].downcase).first if @github_user.nil?
    raise ActiveRecord::RecordNotFound if @github_user.nil?
  end
end
{'fraction_non_alphanumeric': 0.12185870080606923, 'fraction_numerical': 0.001422475106685633, 'mean_word_length': 5.552795031055901, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5620216', 'n_tokens_mistral': 669, 'n_tokens_neox': 635, 'n_words': 126}