Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
JoeyNMT Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Simon Will
JoeyNMT Server
Commits
2bf62cc7
Commit
2bf62cc7
authored
4 years ago
by
Simon Will
Browse files
Options
Downloads
Patches
Plain Diff
Allow querying feedback with limit and offset
parent
84168bd4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
joeynmt_server/views/feedback.py
+19
-10
19 additions, 10 deletions
joeynmt_server/views/feedback.py
with
19 additions
and
10 deletions
joeynmt_server/views/feedback.py
+
19
−
10
View file @
2bf62cc7
...
@@ -5,6 +5,7 @@ import traceback
...
@@ -5,6 +5,7 @@ import traceback
from
flask
import
current_app
,
jsonify
,
request
from
flask
import
current_app
,
jsonify
,
request
from
sqlalchemy
import
or_
from
sqlalchemy
import
or_
from
sqlalchemy.orm
import
aliased
from
joeynmt_server.app
import
create_app
,
db
from
joeynmt_server.app
import
create_app
,
db
from
joeynmt_server.models
import
Feedback
,
Parse
from
joeynmt_server.models
import
Feedback
,
Parse
...
@@ -75,18 +76,26 @@ def list_feedback():
...
@@ -75,18 +76,26 @@ def list_feedback():
@current_app.route
(
'
/query_feedback
'
,
methods
=
[
'
POST
'
])
@current_app.route
(
'
/query_feedback
'
,
methods
=
[
'
POST
'
])
def
query_feedback
():
def
query_feedback
():
filters
=
request
.
json
filters
=
request
.
json
query
=
db
.
session
.
query
(
Feedback
,
Parse
).
outerjoin
(
fb_query
=
Feedback
.
query
Parse
,
Feedback
.
nl
==
Parse
.
nl
)
if
'
user_id
'
in
filters
:
if
'
user_id
'
in
filters
:
query
=
query
.
filter
(
Feedback
.
user_id
==
filters
[
'
user_id
'
])
fb_query
=
fb_query
.
filter_by
(
user_id
=
filters
[
'
user_id
'
])
if
'
limit
'
in
filters
or
'
offset
'
in
filters
:
fb_query
=
fb_query
.
order_by
(
Feedback
.
id
)
if
'
limit
'
in
filters
:
fb_query
=
fb_query
.
limit
(
filters
[
'
limit
'
])
if
'
offset
'
in
filters
:
fb_query
=
fb_query
.
offset
(
filters
[
'
offset
'
])
limited_feedback
=
aliased
(
Feedback
,
fb_query
.
subquery
())
if
'
model
'
in
filters
:
if
'
model
'
in
filters
:
by_id
=
{}
parses_for_model
=
Parse
.
query
.
filter_by
(
model
=
filters
[
'
model
'
])
for
piece
,
parse
in
query
:
parses
=
aliased
(
Parse
,
parses_for_model
.
sub
query
())
if
parse
and
parse
.
model
==
filters
[
'
model
'
]
:
else
:
by_id
[
piece
.
id
]
=
(
piece
,
p
arse
)
parses
=
P
arse
elif
piece
.
id
not
in
by_id
:
by_id
[
piece
.
id
]
=
(
piece
,
None
)
query
=
db
.
session
.
query
(
limited_feedback
,
parses
).
outerjoin
(
query
=
by_id
.
values
(
)
parses
,
limited_feedback
.
nl
==
parses
.
nl
)
joined_feedback
=
[]
joined_feedback
=
[]
for
piece
,
parse
in
query
:
for
piece
,
parse
in
query
:
...
...
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