Commit bc2a9e1f by Rocky Duan

return type of content & disable cache for now

parent 40d2c2ad
...@@ -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"
......
level_limit: 3 level_limit: 3
cache_enabled: true cache_enabled: false
cache_timeout: cache_timeout:
threads_search: 60 threads_search: 10
threads_query: 60 threads_query: 10
...@@ -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
......
...@@ -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)})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment