Skip to content

Commit

Permalink
Filters out duplicate user
Browse files Browse the repository at this point in the history
  • Loading branch information
coder6583 committed Sep 22, 2024
1 parent f4564d9 commit 234f8e3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ def categorize_courses_for_listing(courses)
def write_cuds(cuds)
rowNum = 0
rosterErrors = {}
rosterWarnings = {}
rowCUDs = []
duplicates = Set.new

Expand Down Expand Up @@ -863,7 +864,7 @@ def write_cuds(cuds)
new_cud.delete(:year)

# Build cud
if !user.nil?
if !user.nil? && !existing
cud = @course.course_user_data.new
cud.user = user
params = ActionController::Parameters.new(
Expand Down Expand Up @@ -945,11 +946,11 @@ def write_cuds(cuds)
rowCUDs.each do |cud|
next unless duplicates.include?(cud[:email])

msg = "Validation failed: Duplicate email #{cud[:email]}"
if !rosterErrors.key?(msg)
rosterErrors[msg] = []
msg = "Warning : Duplicate email #{cud[:email]}"
if !rosterWarnings.key?(msg)
rosterWarnings[msg] = []
end
rosterErrors[msg].push(cud)
rosterWarnings[msg].push(cud)
end

return if rosterErrors.empty?
Expand Down

0 comments on commit 234f8e3

Please sign in to comment.