Skip to content

Commit

Permalink
Add bulk_update for migration (EsupPortail#960)
Browse files Browse the repository at this point in the history
  • Loading branch information
AymericJak authored and vsabatie committed Nov 22, 2023
1 parent e4fdb59 commit 7d4f57b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pod/video/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ def update_video_passwords(sender, **kwargs):
videos_to_update = Video.objects.exclude(
Q(password__isnull=True) | Q(password__startswith=("pbkdf2_sha256$"))
)
print("%s videos password to update" % videos_to_update.count())
print("Please note that updating passwords can take a long time (10 minutes for 5000 passwords).")
videos = []
for video in videos_to_update:
video.password = make_password(video.password, hasher="pbkdf2_sha256")
video.save()
videos.append(video)
Video.objects.bulk_update(videos, ['password'], batch_size=1000)
print("update_video_passwords --> OK")


Expand Down

0 comments on commit 7d4f57b

Please sign in to comment.