Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
teknikattan-scoring-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tddd96-grupp1
teknikattan-scoring-system
Commits
a5622fe1
Commit
a5622fe1
authored
4 years ago
by
Victor Löfgren
Browse files
Options
Downloads
Patches
Plain Diff
Add competition_id as paramter to search question api
parent
60478b70
No related branches found
No related tags found
1 merge request
!55
Resolve "Add more api calls"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
server/app/apis/questions.py
+2
-1
2 additions, 1 deletion
server/app/apis/questions.py
server/app/core/controller/get.py
+14
-1
14 additions, 1 deletion
server/app/core/controller/get.py
server/app/core/parsers.py
+1
-0
1 addition, 0 deletions
server/app/core/parsers.py
with
17 additions
and
2 deletions
server/app/apis/questions.py
+
2
−
1
View file @
a5622fe1
...
...
@@ -60,12 +60,12 @@ class QuestionSearch(Resource):
def
get
(
self
,
CID
):
args
=
question_search_parser
.
parse_args
(
strict
=
True
)
print
(
"
fadsfdas
"
)
name
=
args
.
get
(
"
name
"
)
# total_score = args.get("total_score")
slide_id
=
args
.
get
(
"
slide_id
"
)
type_id
=
args
.
get
(
"
type_id
"
)
competition_id
=
args
.
get
(
"
competition_id
"
)
page
=
args
.
get
(
"
page
"
,
0
)
page_size
=
args
.
get
(
"
page_size
"
,
15
)
order
=
args
.
get
(
"
order
"
,
1
)
...
...
@@ -75,6 +75,7 @@ class QuestionSearch(Resource):
name
=
name
,
type_id
=
type_id
,
slide_id
=
slide_id
,
competition_id
=
competition_id
,
page
=
page
,
page_size
=
page_size
,
order
=
order
,
...
...
This diff is collapsed.
Click to expand it.
server/app/core/controller/get.py
+
14
−
1
View file @
a5622fe1
...
...
@@ -44,7 +44,15 @@ def search_user(email=None, name=None, city_id=None, role_id=None, page=0, page_
def
search_questions
(
name
=
None
,
total_score
=
None
,
type_id
=
None
,
slide_id
=
None
,
page
=
0
,
page_size
=
15
,
order
=
1
,
order_by
=
None
name
=
None
,
total_score
=
None
,
type_id
=
None
,
slide_id
=
None
,
competition_id
=
None
,
page
=
0
,
page_size
=
15
,
order
=
1
,
order_by
=
None
,
):
query
=
Question
.
query
if
name
:
...
...
@@ -55,6 +63,11 @@ def search_questions(
query
=
query
.
filter
(
Question
.
type_id
==
type_id
)
if
slide_id
:
query
=
query
.
filter
(
Question
.
slide_id
==
slide_id
)
if
competition_id
:
slide_ids
=
set
(
[
x
.
id
for
x
in
Slide
.
query
.
filter
(
Slide
.
competition_id
==
competition_id
).
all
()]
)
# TODO: Filter using database instead of creating a set of slide_ids
query
=
query
.
filter
(
Question
.
slide_id
.
in_
(
slide_ids
))
order_column
=
Question
.
id
# Default order_by
if
order_by
:
...
...
This diff is collapsed.
Click to expand it.
server/app/core/parsers.py
+
1
−
0
View file @
a5622fe1
...
...
@@ -68,3 +68,4 @@ question_search_parser.add_argument("name", type=str, default=None, location="js
# question_parser.add_argument("total_score", type=int)
question_search_parser
.
add_argument
(
"
slide_id
"
,
type
=
int
,
default
=
None
,
location
=
"
json
"
)
question_search_parser
.
add_argument
(
"
type_id
"
,
type
=
int
,
default
=
None
,
location
=
"
json
"
)
question_search_parser
.
add_argument
(
"
competition_id
"
,
type
=
int
,
default
=
None
,
location
=
"
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