Class: CheckRepoStatusWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/check_repo_status_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(repo_full_name, removed = false) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/workers/check_repo_status_worker.rb', line 5

def perform(repo_full_name, removed = false)
  response = Typhoeus.head("https://github.com/#{repo_full_name}")

  if response.response_code == 404
    repo = GithubRepository.includes(:projects).find_by_full_name(repo_full_name)
    if repo
      status = removed ? nil : 'Removed'
      repo.update_attribute(:status, status) if !repo.private?
      repo.projects.each do |project|
        next unless ['bower', 'go', 'elm', 'alcatraz', 'julia', 'nimble'].include?(project.platform.downcase)
        project.update_attribute(:status, status)
      end
    end
  end
end