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
7489a662
Commit
7489a662
authored
Aug 02, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed seed file bug & reduce seed amount
parent
8aa6d762
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
Rakefile
+11
-9
models/comment_thread.rb
+1
-1
No files found.
Rakefile
View file @
7489a662
...
...
@@ -86,17 +86,15 @@ namespace :db do
Subscription
.
delete_all
end
THREADS_PER_COMMENTABLE
=
50
THREADS_PER_COMMENTABLE
=
15
TOP_COMMENTS_PER_THREAD
=
3
ADDITIONAL_COMMENTS_PER_THREAD
=
10
ADDITIONAL_COMMENTS_PER_THREAD
=
5
COURSE_ID
=
"MITx/6.002x/2012_Fall"
def
generate_comments_for
(
commentable_id
)
level_limit
=
YAML
.
load_file
(
"config/application.yml"
)[
"level_limit"
]
thread_seeds
=
[
{
title:
"This is really interesting"
,
body:
"best I've ever seen!"
},
{
title:
"We can probably make this better"
,
body:
"Let's do it"
},
...
...
@@ -134,24 +132,28 @@ namespace :db do
THREADS_PER_COMMENTABLE
.
times
do
thread_seed
=
thread_seeds
.
sample
comment_thread
=
CommentThread
.
new
(
commentable_id:
commentable_id
,
body:
thread_seed
[
:body
],
title:
thread_seed
[
:title
],
course_id:
"1"
)
inner_top_comments
=
[]
comment_thread
=
CommentThread
.
new
(
commentable_id:
commentable_id
,
body:
thread_seed
[
:body
],
title:
thread_seed
[
:title
])
comment_thread
.
author
=
users
.
sample
comment_thread
.
tags
=
tag_seeds
.
sort_by
{
rand
}[
0
..
2
].
join
(
","
)
comment_thread
.
course_id
=
COURSE_ID
comment_thread
.
save!
threads
<<
comment_thread
TOP_COMMENTS_PER_THREAD
.
times
do
comment
=
comment_thread
.
comments
.
new
(
body:
comment_body_seeds
.
sample
,
course_id:
"1"
)
comment
=
comment_thread
.
comments
.
new
(
body:
comment_body_seeds
.
sample
)
comment
.
author
=
users
.
sample
comment
.
endorsed
=
[
true
,
false
].
sample
comment
.
comment_thread
=
comment_thread
comment
.
course_id
=
COURSE_ID
comment
.
save!
top_comments
<<
comment
inner_top_comments
<<
comment
end
ADDITIONAL_COMMENTS_PER_THREAD
.
times
do
comment
=
top_comments
.
sample
sub_comment
=
comment
.
children
.
new
(
body:
comment_body_seeds
.
sample
,
course_id:
"1"
)
comment
=
inner_
top_comments
.
sample
sub_comment
=
comment
.
children
.
new
(
body:
comment_body_seeds
.
sample
)
sub_comment
.
author
=
users
.
sample
sub_comment
.
endorsed
=
[
true
,
false
].
sample
sub_comment
.
comment_thread
=
comment_thread
...
...
@@ -188,7 +190,7 @@ namespace :db do
beginning_time
=
Time
.
now
users
=
(
1
..
10
).
map
{
|
id
|
User
.
find_or_create_by
(
external_id:
id
.
to_s
)}
users
=
(
1
..
5
).
map
{
|
id
|
User
.
find_or_create_by
(
external_id:
id
.
to_s
)}
=begin
3.times do
other_user = users[1..9].sample
...
...
models/comment_thread.rb
View file @
7489a662
...
...
@@ -33,7 +33,7 @@ class CommentThread < Content
end
end
belongs_to
:author
,
class_name:
"User"
,
inverse_of: :comment_threads
,
index:
true
belongs_to
:author
,
class_name:
"User"
,
inverse_of: :comment_threads
,
index:
true
#, autosave: true
has_many
:comments
,
dependent: :destroy
#, autosave: true# Use destroy to envoke callback on the top-level comments TODO async
attr_accessible
:title
,
:body
,
:course_id
,
:commentable_id
,
:anonymous
...
...
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