Skip to content

Commit

Permalink
Do not update project info from GitHub anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmike committed May 29, 2014
1 parent e337295 commit ad75feb
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 68 deletions.
61 changes: 0 additions & 61 deletions app/models/project.rb
Expand Up @@ -17,36 +17,6 @@ class Project < ActiveRecord::Base
scope :enabled, -> { where(disabled: false) }
scope :disabled, -> { where(disabled: true) }

def update_github_info repo
self.github_id = repo.id
self.name = repo.name
self.full_name = repo.full_name
self.source_full_name = repo.source.full_name rescue ''
self.description = repo.description
self.watchers_count = repo.watchers_count
self.language = repo.language
self.save!
end

def update_github_collaborators(github_collaborators)
github_logins = github_collaborators.map(&:login)
existing_logins = collaborators.map(&:login)

collaborators.each do |collaborator|
unless github_logins.include?(collaborator.login)
collaborator.mark_for_destruction
end
end

github_collaborators.each do |github_collaborator|
unless existing_logins.include?(github_collaborator.login)
collaborators.build(login: github_collaborator.login)
end
end

save!
end

def github_url
"https://github.com/#{full_name}" if full_name.present?
end
Expand Down Expand Up @@ -164,37 +134,6 @@ def self.update_cache
end
end

def github_info
client = Octokit::Client.new \
:client_id => CONFIG['github']['key'],
:client_secret => CONFIG['github']['secret']
if github_id.present?
client.get("/repositories/#{github_id}")
else
client.repo(full_name)
end
end

def github_collaborators
client = Octokit::Client.new \
:client_id => CONFIG['github']['key'],
:client_secret => CONFIG['github']['secret']
client.get("/repos/#{full_name}/collaborators") +
(client.get("/orgs/#{full_name.split('/').first}/members") rescue [])
end

def update_info
begin
update_github_info(github_info)
update_github_collaborators(github_collaborators)
rescue Octokit::BadGateway, Octokit::NotFound, Octokit::InternalServerError,
Errno::ETIMEDOUT, Faraday::Error::ConnectionFailed => e
Rails.logger.info "Project ##{id}: #{e.class} happened"
rescue StandardError => e
Airbrake.notify(e)
end
end

def tips_to_pay
tips.select(&:to_pay?)
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/home/index.html.haml
Expand Up @@ -26,7 +26,7 @@
.col-lg-3
%h2 How it works?
%p
Fundraisers create projects and collect funds to make something happen.
Fundraisers collect funds and distribute them to make something happen.
%p
%a.btn.btn-primary{href: faq_path} Frequently Asked Questions »
.col-lg-3
Expand Down
6 changes: 0 additions & 6 deletions lib/bitcoin_tipper.rb
Expand Up @@ -14,12 +14,6 @@ def self.work
end
end

Rails.logger.info "Updating projects info..."
Project.enabled.each do |project|
Rails.logger.info " Project #{project.id} #{project.full_name}"
project.update_info
end

self.create_sendmany

Rails.logger.info "Traversing sendmanies..."
Expand Down

0 comments on commit ad75feb

Please sign in to comment.