Skip to content

Commit

Permalink
Move callback into the correct model
Browse files Browse the repository at this point in the history
update_staging_workflow_on_backend callback was moved into
staging_project model.
  • Loading branch information
DavidKang committed Nov 16, 2018
1 parent a56f59d commit bb92227
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/api/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ class Project < ApplicationRecord
@commit_opts = {}
end

after_save :update_staging_workflow_on_backend
after_destroy :update_staging_workflow_on_backend

has_many :relationships, dependent: :destroy, inverse_of: :project
has_many :packages, inverse_of: :project do
def autocomplete(search)
Expand Down Expand Up @@ -1747,13 +1744,6 @@ def has_local_distribution(project_name, repository)
linked_repository.name == repository
end
end

def update_staging_workflow_on_backend
return unless staging_workflow_id

staging_workflow.reload
staging_workflow.write_to_backend
end
end
# rubocop:enable Metrics/ClassLength

Expand Down
10 changes: 10 additions & 0 deletions src/api/app/models/staging/staging_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class StagingProject < Project

default_scope { where.not(staging_workflow: nil) }

after_save :update_staging_workflow_on_backend
after_destroy :update_staging_workflow_on_backend

def staging_identifier
name[/.*:Staging:(.*)/, 1]
end
Expand Down Expand Up @@ -146,5 +149,12 @@ def set_buildinfo

@broken_packages.reject! { |package| package['state'] == 'unresolvable' } if @building_repositories.present?
end

def update_staging_workflow_on_backend
return unless staging_workflow_id

staging_workflow.reload
staging_workflow.write_to_backend
end
end
end

0 comments on commit bb92227

Please sign in to comment.