Skip to content

Commit

Permalink
Update webhooks (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
johanla0 authored Oct 16, 2023
1 parent 3dacb6e commit e96198c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions app/controllers/api/github_webhooks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ def checks
repository = Repository.find_by(github_id: repository_params[:id])
return render(json: { error: 'not_found' }, status: :not_found) if repository.blank?

last_check = repository.checks.last
return render(json: { error: 'conflict' }, status: :conflict) if last_check.present? && (last_check.created? || last_check.in_process?)
return render(json: { error: 'conflict' }, status: :conflict) if repository.being_checked?

CheckRepositoryJob.perform_async(repository.id)
render json: { message: 'created' }, status: :ok
Expand Down
4 changes: 4 additions & 0 deletions app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ def check_enabled?
def check_disabled?
!check_enabled?
end

def being_checked?
checks.last.present? && (checks.last.created? || checks.last.in_process?)
end
end

0 comments on commit e96198c

Please sign in to comment.