Skip to content

Commit

Permalink
Add script to set ContainerRun.md5 on existing runs, as part of #751.
Browse files Browse the repository at this point in the history
  • Loading branch information
donkirkby committed Mar 2, 2019
1 parent 39ebdf4 commit 2d96b70
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions kive/container/management/commands/set_run_md5s.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from __future__ import print_function

from django.core.management.base import BaseCommand

from container.models import ContainerRun


class Command(BaseCommand):
help = "Set MD5 on any runs that still have a blank."

def handle(self, **kwargs):
batch_size = 100
run_count = 0
print('Starting.')
while True:
runs = ContainerRun.objects.filter(md5='')[:batch_size]
batch_count = len(runs)
if not batch_count:
break
for run in runs:
run.set_md5()
run.save()
run_count += batch_count
print('Set MD5 on {} runs.'.format(run_count))
print('Done.')

0 comments on commit 2d96b70

Please sign in to comment.