Skip to content

Commit

Permalink
Fix completion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
iHiD committed Jan 14, 2025
1 parent a7e77ec commit 6945a91
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/commands/bootcamp/solution/complete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def schedule_deferred_jobs!
Bootcamp::UpdateUserLevel.defer(user)
end

def user_project = Bootcamp::UserProject.for!(user, project)
def user_project
Bootcamp::UserProject.for!(user, project)
rescue ActiveRecord::RecordNotFound
Bootcamp::UserProject::Create.(user, project)
end

delegate :user, :project, to: :solution
end
4 changes: 2 additions & 2 deletions app/commands/bootcamp/user_project/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ class Bootcamp::UserProject::Create
initialize_with :user, :project

def call
find_or_create.tap do |up|
create_or_find.tap do |up|
Bootcamp::UserProject::UpdateStatus.(up)
end
end

def find_or_create
def create_or_find
Bootcamp::UserProject.create!(user:, project:)
rescue StandardError
Bootcamp::UserProject.find_by!(user:, project:)
Expand Down

0 comments on commit 6945a91

Please sign in to comment.