Class: UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#contributionsObject


20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/users_controller.rb', line 20

def contributions
  find_user
  @contributions = @user.github_contributions.with_repo
                        .joins(:github_repository)
                        .where('github_repositories.owner_id != ?', @user.github_id.to_s)
                        .where('github_repositories.fork = ?', false)
                        .where('github_repositories.private = ?', false)
                        .includes(:github_repository)
                        .order('count DESC').paginate(page: page_number)
end

#projectsObject


31
32
33
34
35
# File 'app/controllers/users_controller.rb', line 31

def projects
  find_user
  order = params[:sort] == "contributions" ? "github_repositories.github_contributions_count ASC, projects.rank DESC, projects.created_at DESC" : 'projects.rank DESC, projects.created_at DESC'
  @projects = @user.projects.joins(:github_repository).order(order).paginate(page: page_number)
end

#repositoriesObject


15
16
17
18
# File 'app/controllers/users_controller.rb', line 15

def repositories
  find_user
  @repositories = @user.github_repositories.open_source.source.order('stargazers_count DESC').paginate(page: page_number)
end

#showObject


2
3
4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/users_controller.rb', line 2

def show
  find_user
  @repositories = @user.github_repositories.open_source.source.order('stargazers_count DESC').limit(10)
  @favourite_projects = @user.top_favourite_projects
  @contributions = @user.github_contributions.with_repo
                        .joins(:github_repository)
                        .where('github_repositories.owner_id != ?', @user.github_id.to_s)
                        .where('github_repositories.fork = ?', false)
                        .where('github_repositories.private = ?', false)
                        .includes(:github_repository)
                        .order('count DESC').limit(10)
end