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
bc2a9e1f
Commit
bc2a9e1f
authored
Aug 20, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return type of content & disable cache for now
parent
40d2c2ad
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
18 deletions
+20
-18
Rakefile
+3
-3
config/application.yml
+3
-3
models/comment.rb
+8
-7
models/comment_thread.rb
+6
-5
No files found.
Rakefile
View file @
bc2a9e1f
...
@@ -51,9 +51,9 @@ namespace :db do
...
@@ -51,9 +51,9 @@ namespace :db do
Subscription
.
delete_all
Subscription
.
delete_all
end
end
THREADS_PER_COMMENTABLE
=
3
THREADS_PER_COMMENTABLE
=
20
TOP_COMMENTS_PER_THREAD
=
2
TOP_COMMENTS_PER_THREAD
=
3
ADDITIONAL_COMMENTS_PER_THREAD
=
1
ADDITIONAL_COMMENTS_PER_THREAD
=
5
COURSE_ID
=
"MITx/6.002x/2012_Fall"
COURSE_ID
=
"MITx/6.002x/2012_Fall"
...
...
config/application.yml
View file @
bc2a9e1f
level_limit
:
3
level_limit
:
3
cache_enabled
:
tru
e
cache_enabled
:
fals
e
cache_timeout
:
cache_timeout
:
threads_search
:
6
0
threads_search
:
1
0
threads_query
:
6
0
threads_query
:
1
0
models/comment.rb
View file @
bc2a9e1f
...
@@ -49,13 +49,14 @@ class Comment < Content
...
@@ -49,13 +49,14 @@ class Comment < Content
self
.
class
.
hash_tree
(
subtree
(
sort:
sort_by_parent_and_time
)).
first
self
.
class
.
hash_tree
(
subtree
(
sort:
sort_by_parent_and_time
)).
first
else
else
as_document
.
slice
(
*
%w[body course_id endorsed anonymous created_at updated_at at_position_list]
)
as_document
.
slice
(
*
%w[body course_id endorsed anonymous created_at updated_at at_position_list]
)
.
merge
(
"id"
=>
_id
)
.
merge
(
"id"
=>
_id
)
.
merge
(
"user_id"
=>
author
.
id
)
.
merge
(
"user_id"
=>
author
.
id
)
.
merge
(
"username"
=>
author
.
username
)
.
merge
(
"username"
=>
author
.
username
)
.
merge
(
"depth"
=>
depth
)
.
merge
(
"depth"
=>
depth
)
.
merge
(
"closed"
=>
comment_thread
.
closed
)
.
merge
(
"closed"
=>
comment_thread
.
closed
)
.
merge
(
"thread_id"
=>
comment_thread
.
id
)
.
merge
(
"thread_id"
=>
comment_thread
.
id
)
.
merge
(
"votes"
=>
votes
.
slice
(
*
%w[count up_count down_count point]
))
.
merge
(
"votes"
=>
votes
.
slice
(
*
%w[count up_count down_count point]
))
.
merge
(
"type"
=>
"comment"
)
end
end
end
end
...
...
models/comment_thread.rb
View file @
bc2a9e1f
...
@@ -149,11 +149,12 @@ class CommentThread < Content
...
@@ -149,11 +149,12 @@ class CommentThread < Content
def
to_hash
(
params
=
{})
def
to_hash
(
params
=
{})
doc
=
as_document
.
slice
(
*
%w[title body course_id anonymous commentable_id created_at updated_at at_position_list closed]
)
doc
=
as_document
.
slice
(
*
%w[title body course_id anonymous commentable_id created_at updated_at at_position_list closed]
)
.
merge
(
"id"
=>
_id
)
.
merge
(
"id"
=>
_id
)
.
merge
(
"user_id"
=>
author
.
id
)
.
merge
(
"user_id"
=>
author
.
id
)
.
merge
(
"username"
=>
author
.
username
)
.
merge
(
"username"
=>
author
.
username
)
.
merge
(
"votes"
=>
votes
.
slice
(
*
%w[count up_count down_count point]
))
.
merge
(
"votes"
=>
votes
.
slice
(
*
%w[count up_count down_count point]
))
.
merge
(
"tags"
=>
tags_array
)
.
merge
(
"tags"
=>
tags_array
)
.
merge
(
"type"
=>
"thread"
)
if
params
[
:recursive
]
if
params
[
:recursive
]
doc
=
doc
.
merge
(
"children"
=>
root_comments
.
map
{
|
c
|
c
.
to_hash
(
recursive:
true
)})
doc
=
doc
.
merge
(
"children"
=>
root_comments
.
map
{
|
c
|
c
.
to_hash
(
recursive:
true
)})
...
...
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