Skip to content
Snippets Groups Projects
Commit a9a80c1e authored by Bastien Abadie's avatar Bastien Abadie
Browse files

Display progression on slow migration

parent 6b6aa475
No related branches found
No related tags found
1 merge request!18Transcription search
......@@ -7,7 +7,13 @@ from documents.models import DocumentType
def transcription_to_document(apps, schema_editor):
Document = apps.get_model('documents', 'Document')
Transcription = apps.get_model('documents', 'Transcription')
for ts in Transcription.objects.all():
nb = Transcription.objects.all().count()
last = 0
for i,ts in enumerate(Transcription.objects.all()):
percent = int(100.0 * (i+1) / nb)
if percent % 5 == 0 and last != percent:
print(' > {}% => {} / {}'.format(percent, i, nb))
last = percent
new_ts = Transcription(line=ts.line, score=ts.score, text=ts.text)
new_ts.document_ptr = Document.objects.create(type=DocumentType.Transcription, name="Transcription '{}'".format(ts.text))
new_ts.save()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment