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
485b11b1
Commit
485b11b1
authored
Jun 26, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache depth for single depth retrieval
parent
018e71a8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
db/migrate/005_add_ancestry_depth_to_comments.rb
+9
-0
models/comment.rb
+2
-2
No files found.
db/migrate/005_add_ancestry_depth_to_comments.rb
0 → 100644
View file @
485b11b1
class
AddAncestryDepthToComments
<
ActiveRecord
::
Migration
def
self
.
up
add_column
:comments
,
:ancestry_depth
,
:integer
,
:default
=>
0
end
def
self
.
down
remove_column
:comments
,
:ancestry_depth
end
end
models/comment.rb
View file @
485b11b1
...
...
@@ -6,7 +6,7 @@ class Comment < ActiveRecord::Base
attr_accessible
:body
,
:title
,
:user_id
,
:course_id
,
:comment_thread_id
has_ancestry
has_ancestry
:cache_depth
=>
true
belongs_to
:comment_thread
...
...
@@ -18,7 +18,7 @@ class Comment < ActiveRecord::Base
validates_presence_of
:comment_thread_id
def
self
.
hash_tree
(
nodes
)
nodes
.
map
{
|
node
,
sub_nodes
|
node
.
to_hash
.
merge
(
:children
=>
hash_tree
(
sub_nodes
).
compact
,
:depth
=>
node
.
depth
)}
nodes
.
map
{
|
node
,
sub_nodes
|
node
.
to_hash
.
merge
(
:children
=>
hash_tree
(
sub_nodes
).
compact
)}
end
def
to_hash_tree
...
...
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