Skip to content

Commit

Permalink
Update github repos after new versions/tags are created
Browse files Browse the repository at this point in the history
Related to #487
  • Loading branch information
andrew committed Mar 24, 2016
1 parent 87d679a commit 695d576
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/models/github_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ class GithubTag < ActiveRecord::Base
scope :published, -> { where('published_at IS NOT NULL') }

after_commit :send_notifications_async, on: :create
after_commit :update_github_repo_async, on: :create

def to_s
name
end

def update_github_repo_async
GithubUpdateWorker.perform_async(github_repository.full_name)
end

def send_notifications_async
return if published_at && published_at < 1.week.ago
TagNotificationsWorker.perform_async(self.id) if has_projects?
Expand Down
5 changes: 5 additions & 0 deletions app/models/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Version < ActiveRecord::Base
has_many :dependencies, dependent: :delete_all

after_commit :send_notifications_async, on: :create
after_commit :update_github_repo_async, on: :create

scope :newest_first, -> { order('versions.published_at DESC') }

Expand Down Expand Up @@ -48,6 +49,10 @@ def send_notifications_async
VersionNotificationsWorker.perform_async(self.id)
end

def update_github_repo_async
project.update_github_repo_async
end

def send_notifications
notify_subscribers
notify_firehose
Expand Down

0 comments on commit 695d576

Please sign in to comment.