Skip to content

Commit

Permalink
OTWO-7203 position create issue fix (#1780)
Browse files Browse the repository at this point in the history
* OTWO-7203 position create issue fix

* OTWO-7203 rubocop fix
  • Loading branch information
Niharika1117 authored Apr 4, 2024
1 parent e99ab09 commit edb05f2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/models/account/position_core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def ensure_position_or_alias!(project, name, try_create: false, position_attribu
return unless existing_position || try_create

Account.transaction do
if existing_position && project.best_analysis.contributor_facts.find_by(name_id: existing_position.name_id)
if check_existing_contributions?(project, existing_position)
create_or_update_alias(project, name, existing_position, position_attributes)
else
attributes = position_attributes.merge(account: account, project: project, committer_name: name.name)
Expand All @@ -62,6 +62,11 @@ def ensure_position_or_alias!(project, name, try_create: false, position_attribu
end
end

def check_existing_contributions?(project, position)
contributor_facts = project.best_analysis.contributor_facts
position && contributor_facts.present? && contributor_facts.find_by(name_id: position.name_id)
end

def logos
logo_ids = preloaded_positions.map { |position| position.project.logo_id }.compact
@logos ||= Logo.find(logo_ids).index_by(&:id)
Expand Down

0 comments on commit edb05f2

Please sign in to comment.