Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cs_comments_service
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
cs_comments_service
Commits
06c97e53
Commit
06c97e53
authored
Jul 11, 2014
by
Alan Boudreault
Committed by
Jonathan Piacenti
Aug 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the ability to query multiple group ids
parent
2f78ff2e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
1 deletions
+20
-1
api/comment_threads.rb
+7
-0
api/commentables.rb
+7
-0
spec/api/comment_thread_spec.rb
+4
-0
spec/api/search_spec.rb
+2
-1
No files found.
api/comment_threads.rb
View file @
06c97e53
...
@@ -3,6 +3,13 @@ get "#{APIPREFIX}/threads" do # retrieve threads by course
...
@@ -3,6 +3,13 @@ get "#{APIPREFIX}/threads" do # retrieve threads by course
threads
=
Content
.
where
({
"_type"
=>
"CommentThread"
,
"course_id"
=>
params
[
"course_id"
]})
threads
=
Content
.
where
({
"_type"
=>
"CommentThread"
,
"course_id"
=>
params
[
"course_id"
]})
if
params
[
:commentable_ids
]
if
params
[
:commentable_ids
]
threads
=
threads
.
in
({
"commentable_id"
=>
params
[
:commentable_ids
].
split
(
","
)})
threads
=
threads
.
in
({
"commentable_id"
=>
params
[
:commentable_ids
].
split
(
","
)})
#if a group id is sent, then process the set of threads with that group id or with no group id
group_ids
=
get_group_ids_from_params
(
params
)
if
not
group_ids
.
empty?
threads
=
threads
.
any_of
(
{
:group_id
.
in
=>
group_ids
},
{
:group_id
.
exists
=>
false
},
)
end
end
handle_threads_query
(
handle_threads_query
(
...
...
api/commentables.rb
View file @
06c97e53
...
@@ -7,6 +7,13 @@ get "#{APIPREFIX}/:commentable_id/threads" do |commentable_id|
...
@@ -7,6 +7,13 @@ get "#{APIPREFIX}/:commentable_id/threads" do |commentable_id|
threads
=
Content
.
where
({
"_type"
=>
"CommentThread"
,
"commentable_id"
=>
commentable_id
})
threads
=
Content
.
where
({
"_type"
=>
"CommentThread"
,
"commentable_id"
=>
commentable_id
})
if
params
[
"course_id"
]
if
params
[
"course_id"
]
threads
=
threads
.
where
({
"course_id"
=>
params
[
"course_id"
]})
threads
=
threads
.
where
({
"course_id"
=>
params
[
"course_id"
]})
threads
=
Content
.
where
(
_type
:"CommentThread"
,
commentable_id:
commentable_id
)
group_ids
=
get_group_ids_from_params
(
params
)
if
not
group_ids
.
empty?
threads
=
threads
.
any_of
(
{
:group_id
.
in
=>
group_ids
},
{
:group_id
.
exists
=>
false
},
)
end
end
handle_threads_query
(
handle_threads_query
(
...
...
spec/api/comment_thread_spec.rb
View file @
06c97e53
...
@@ -67,6 +67,10 @@ describe "app" do
...
@@ -67,6 +67,10 @@ describe "app" do
@threads
[
"t2"
].
save!
@threads
[
"t2"
].
save!
rs
=
thread_result
course_id:
"omg"
,
group_ids:
"100,101"
,
sort_order:
"asc"
rs
=
thread_result
course_id:
"omg"
,
group_ids:
"100,101"
,
sort_order:
"asc"
rs
.
length
.
should
==
2
rs
.
length
.
should
==
2
rs
.
each_with_index
{
|
res
,
i
|
check_thread_result_json
(
nil
,
@threads
[
"t
#{
i
+
1
}
"
],
res
)
res
[
"course_id"
].
should
==
"omg"
}
end
end
it
"returns only threads where course id and group id match or group id is nil"
do
it
"returns only threads where course id and group id match or group id is nil"
do
@threads
[
"t1"
].
course_id
=
"omg"
@threads
[
"t1"
].
course_id
=
"omg"
...
...
spec/api/search_spec.rb
View file @
06c97e53
...
@@ -127,7 +127,8 @@ describe "app" do
...
@@ -127,7 +127,8 @@ describe "app" do
it
"by group_ids"
do
it
"by group_ids"
do
get
"/api/v1/search/threads"
,
text:
"text"
,
group_ids:
"1,2"
get
"/api/v1/search/threads"
,
text:
"text"
,
group_ids:
"1,2"
expected_ids
=
(
0
..
29
).
find_all
{
|
i
|
i
%
5
==
0
||
i
%
5
==
1
||
i
%
5
==
2
}
expected_ids
=
(
0
..
29
).
find_all
{
|
i
|
i
%
5
==
0
||
i
%
5
==
1
}
expected_ids
.
concat
((
0
..
29
).
find_all
{
|
i
|
i
%
5
==
2
})
assert_response_contains
(
expected_ids
)
assert_response_contains
(
expected_ids
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment