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
faea8987
Commit
faea8987
authored
4 years ago
by
Bastien Abadie
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix-542' into 'master'
Fix stale read issue on bulk transcriptions endpoint Closes
#542
See merge request
!1075
parents
8708a288
8b90ba9a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1075
Fix stale read issue on bulk transcriptions endpoint
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/api/ml.py
+6
-1
6 additions, 1 deletion
arkindex/documents/api/ml.py
arkindex/documents/tests/test_bulk_element_transcriptions.py
+3
-3
3 additions, 3 deletions
arkindex/documents/tests/test_bulk_element_transcriptions.py
with
9 additions
and
4 deletions
arkindex/documents/api/ml.py
+
6
−
1
View file @
faea8987
...
...
@@ -192,7 +192,12 @@ class ElementTranscriptionsBulk(CreateAPIView):
def
get_queryset
(
self
):
if
not
self
.
request
:
return
Element
.
objects
.
none
()
return
Element
.
objects
.
filter
(
corpus__in
=
Corpus
.
objects
.
writable
(
self
.
request
.
user
))
# Load elements and their zones from the default DB to avoid
# a stale read issue when an element is created by a worker
# and this endpoint is immediately used after to create transcriptions
return
Element
.
objects
.
filter
(
corpus__in
=
Corpus
.
objects
.
writable
(
self
.
request
.
user
)
).
using
(
'
default
'
).
select_related
(
'
zone
'
)
def
get_serializer_context
(
self
):
context
=
super
().
get_serializer_context
()
...
...
This diff is collapsed.
Click to expand it.
arkindex/documents/tests/test_bulk_element_transcriptions.py
+
3
−
3
View file @
faea8987
...
...
@@ -122,7 +122,7 @@ class TestBulkElementTranscriptions(FixtureAPITestCase):
self
.
assertEqual
(
created_elts
.
count
(),
1
)
self
.
client
.
force_login
(
self
.
internal_user
)
with
self
.
assertNumQueries
(
1
7
):
with
self
.
assertNumQueries
(
1
6
):
response
=
self
.
client
.
post
(
reverse
(
'
api:element-transcriptions-bulk
'
,
kwargs
=
{
'
pk
'
:
self
.
page
.
id
}),
format
=
'
json
'
,
...
...
@@ -166,7 +166,7 @@ class TestBulkElementTranscriptions(FixtureAPITestCase):
}
self
.
client
.
force_login
(
self
.
internal_user
)
with
self
.
assertNumQueries
(
1
7
):
with
self
.
assertNumQueries
(
1
6
):
response
=
self
.
client
.
post
(
reverse
(
'
api:element-transcriptions-bulk
'
,
kwargs
=
{
'
pk
'
:
self
.
page
.
id
}),
format
=
'
json
'
,
...
...
@@ -286,7 +286,7 @@ class TestBulkElementTranscriptions(FixtureAPITestCase):
}
self
.
client
.
force_login
(
self
.
internal_user
)
with
self
.
assertNumQueries
(
1
7
):
with
self
.
assertNumQueries
(
1
6
):
response
=
self
.
client
.
post
(
reverse
(
'
api:element-transcriptions-bulk
'
,
kwargs
=
{
'
pk
'
:
self
.
page
.
id
}),
format
=
'
json
'
,
...
...
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