Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
a9a80c1e
Commit
a9a80c1e
authored
6 years ago
by
Bastien Abadie
Browse files
Options
Downloads
Patches
Plain Diff
Display progression on slow migration
parent
6b6aa475
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!18
Transcription search
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/documents/migrations/0014_auto_20180502_0852.py
+7
-1
7 additions, 1 deletion
src/documents/migrations/0014_auto_20180502_0852.py
with
7 additions
and
1 deletion
src/documents/migrations/0014_auto_20180502_0852.py
+
7
−
1
View file @
a9a80c1e
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment