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
916fe206
Commit
916fe206
authored
Sep 09, 2014
by
Zia Fazal
Committed by
Jonathan Piacenti
Aug 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api to get total and active posts for a course
allow course with slashes
parent
192da911
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
api/comment_threads.rb
+12
-0
spec/api/comment_thread_spec.rb
+25
-0
No files found.
api/comment_threads.rb
View file @
916fe206
...
@@ -93,3 +93,15 @@ delete "#{APIPREFIX}/threads/:thread_id" do |thread_id|
...
@@ -93,3 +93,15 @@ delete "#{APIPREFIX}/threads/:thread_id" do |thread_id|
thread
.
destroy
thread
.
destroy
thread
.
to_hash
.
to_json
thread
.
to_hash
.
to_json
end
end
get
"
#{
APIPREFIX
}
/courses/*/stats"
do
|
course_id
|
# retrieve stats by course
begin
threads
=
Content
.
where
(
_type:
"CommentThread"
,
course_id:
course_id
)
active_threads
=
threads
.
where
(
:last_activity_at
.
gte
=>
1
.
day
.
ago
)
course_stats
=
{
"num_threads"
=>
threads
.
count
,
"num_active_threads"
=>
active_threads
.
count
}
course_stats
.
to_json
end
end
spec/api/comment_thread_spec.rb
View file @
916fe206
...
@@ -490,6 +490,31 @@ describe "app" do
...
@@ -490,6 +490,31 @@ describe "app" do
parse
(
last_response
.
body
).
first
.
should
==
I18n
.
t
(
:requested_object_not_found
)
parse
(
last_response
.
body
).
first
.
should
==
I18n
.
t
(
:requested_object_not_found
)
end
end
# Test active and non active thread count for a course
it
"test the number of active and non active threads for a course"
do
User
.
all
.
delete
Content
.
all
.
delete
@user
=
create_test_user
(
999
)
@threads
=
{}
5
.
times
do
|
n
|
thread_key
=
"t
#{
n
}
"
thread
=
make_thread
(
@user
,
thread_key
,
DFLT_COURSE_ID
,
"pdq"
)
@threads
[
n
]
=
thread
end
time_threshold
=
2
.
day
.
ago
@threads
[
0
].
last_activity_at
=
time_threshold
@threads
[
0
].
save!
@threads
[
1
].
last_activity_at
=
time_threshold
@threads
[
1
].
save!
get
"/api/v1/courses/
#{
DFLT_COURSE_ID
}
/stats"
last_response
.
should
be_ok
response
=
parse
last_response
.
body
response
[
"num_threads"
].
should
==
5
response
[
"num_active_threads"
].
should
==
3
end
def
test_unicode_data
(
text
)
def
test_unicode_data
(
text
)
thread
=
make_thread
(
User
.
first
,
text
,
"unicode_course"
,
"unicode_commentable"
)
thread
=
make_thread
(
User
.
first
,
text
,
"unicode_course"
,
"unicode_commentable"
)
make_comment
(
User
.
first
,
thread
,
text
)
make_comment
(
User
.
first
,
thread
,
text
)
...
...
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