Skip to content

Commit

Permalink
fix: use 1 loop instead of 2
Browse files Browse the repository at this point in the history
  • Loading branch information
varshamenon4 committed Jul 30, 2024
1 parent 973b522 commit 1e27f1a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions edx_exams/apps/core/management/commands/bulk_add_course_staff.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ def add_course_staff_from_csv(self, csv_file, batch_size, batch_delay):
) for row in reader[i:i + batch_size]),
ignore_conflicts=True,
)
time.sleep(batch_delay)

# bulk create course staff
for i in range(0, len(reader), batch_size):
CourseStaffRole.objects.bulk_create(
(CourseStaffRole(
user=User.objects.get(username=row.get('username')),
Expand All @@ -86,3 +82,15 @@ def add_course_staff_from_csv(self, csv_file, batch_size, batch_delay):
ignore_conflicts=True,
)
time.sleep(batch_delay)

# bulk create course staff
# for i in range(0, len(reader), batch_size):
# CourseStaffRole.objects.bulk_create(
# (CourseStaffRole(
# user=User.objects.get(username=row.get('username')),
# course_id=row.get('course_id'),
# role=row.get('role'),
# ) for row in reader[i:i + batch_size]),
# ignore_conflicts=True,
# )
# time.sleep(batch_delay)

0 comments on commit 1e27f1a

Please sign in to comment.