Class: Admin::GithubRepositoriesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/github_repositories_controller.rb

Instance Method Summary collapse

Instance Method Details

#deprecatedObject



29
30
31
# File 'app/controllers/admin/github_repositories_controller.rb', line 29

def deprecated
  @github_repositories = GithubRepository.maintained.where("github_repositories.description ilike '%deprecated%'").order('stargazers_count DESC').paginate(page: params[:page])
end

#indexObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/admin/github_repositories_controller.rb', line 16

def index
  if params[:language].present?
    @language = GithubRepository.language(params[:language].downcase).first.try(:language)
    raise ActiveRecord::RecordNotFound if @language.nil?
    scope = GithubRepository.language(@language)
  else
    scope = GithubRepository
  end

  @languages = GithubRepository.maintained.without_license.with_projects.group('github_repositories.language').count.sort_by(&:last).reverse.first(20)
  @github_repositories = scope.maintained.without_license.with_projects.order("COUNT(projects.id) DESC").group("github_repositories.id").paginate(page: params[:page])
end

#showObject



2
3
4
# File 'app/controllers/admin/github_repositories_controller.rb', line 2

def show
  @github_repository = GithubRepository.find(params[:id])
end

#unmaintainedObject



33
34
35
# File 'app/controllers/admin/github_repositories_controller.rb', line 33

def unmaintained
  @github_repositories = GithubRepository.maintained.where("github_repositories.description ilike '%maintained%'").order('stargazers_count DESC').paginate(page: params[:page])
end

#updateObject



6
7
8
9
10
11
12
13
14
# File 'app/controllers/admin/github_repositories_controller.rb', line 6

def update
  @github_repository = GithubRepository.find(params[:id])
  if @github_repository.update_attributes(github_repository_params)
    @github_repository.update_all_info_async
    redirect_to github_repository_path(@github_repository.owner_name, @github_repository.project_name)
  else
    redirect_to admin_github_repository_path(@github_repository.id)
  end
end