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
1e37411e
Commit
1e37411e
authored
Aug 01, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified rakefile for pagination
parent
353a6981
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
Rakefile
+20
-19
No files found.
Rakefile
View file @
1e37411e
...
@@ -86,9 +86,15 @@ namespace :db do
...
@@ -86,9 +86,15 @@ namespace :db do
Subscription
.
delete_all
Subscription
.
delete_all
end
end
THREADS_PER_COMMENTABLE
=
200
TOP_COMMENTS_PER_THREAD
=
0
ADDITIONAL_COMMENTS_PER_THREAD
=
0
def
generate_comments_for
(
commentable_id
)
def
generate_comments_for
(
commentable_id
)
level_limit
=
YAML
.
load_file
(
"config/application.yml"
)[
"level_limit"
]
level_limit
=
YAML
.
load_file
(
"config/application.yml"
)[
"level_limit"
]
thread_seeds
=
[
thread_seeds
=
[
{
title:
"This is really interesting"
,
body:
"best I've ever seen!"
},
{
title:
"This is really interesting"
,
body:
"best I've ever seen!"
},
{
title:
"We can probably make this better"
,
body:
"Let's do it"
},
{
title:
"We can probably make this better"
,
body:
"Let's do it"
},
...
@@ -121,47 +127,42 @@ namespace :db do
...
@@ -121,47 +127,42 @@ namespace :db do
puts
"Generating threads and comments for
#{
commentable_id
}
..."
puts
"Generating threads and comments for
#{
commentable_id
}
..."
threads
=
[]
threads
=
[]
comments
=
[]
top_comments
=
[]
additional_comments
=
[]
thread_seeds
.
each
do
|
thread_seed
|
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"
)
comment_thread
=
CommentThread
.
new
(
commentable_id:
commentable_id
,
body:
thread_seed
[
:body
],
title:
thread_seed
[
:title
],
course_id:
"1"
)
comment_thread
.
author
=
users
.
sample
comment_thread
.
author
=
users
.
sample
comment_thread
.
tags
=
tag_seeds
.
sort_by
{
rand
}[
0
..
2
].
join
(
","
)
comment_thread
.
tags
=
tag_seeds
.
sort_by
{
rand
}[
0
..
2
].
join
(
","
)
comment_thread
.
save!
comment_thread
.
save!
threads
<<
comment_thread
threads
<<
comment_thread
3
.
times
do
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
,
course_id:
"1"
)
comment
.
author
=
users
.
sample
comment
.
author
=
users
.
sample
comment
.
endorsed
=
[
true
,
false
].
sample
comment
.
endorsed
=
[
true
,
false
].
sample
comment
.
comment_thread
=
comment_thread
comment
.
comment_thread
=
comment_thread
comment
.
save!
comment
.
save!
comments
<<
comment
top_
comments
<<
comment
end
end
10
.
times
do
ADDITIONAL_COMMENTS_PER_THREAD
.
times
do
comment
=
Comment
.
where
(
comment_thread_id:
comment_thread
.
id
).
reject
{
|
c
|
c
.
depth
>=
level_limit
}
.
sample
comment
=
top_comments
.
sample
sub_comment
=
comment
.
children
.
new
(
body:
comment_body_seeds
.
sample
,
course_id:
"1"
)
sub_comment
=
comment
.
children
.
new
(
body:
comment_body_seeds
.
sample
,
course_id:
"1"
)
sub_comment
.
author
=
users
.
sample
sub_comment
.
author
=
users
.
sample
sub_comment
.
endorsed
=
[
true
,
false
].
sample
sub_comment
.
endorsed
=
[
true
,
false
].
sample
sub_comment
.
comment_thread
=
comment_thread
sub_comment
.
comment_thread
=
comment_thread
sub_comment
.
save!
sub_comment
.
save!
comments
<<
sub_comment
additional_comments
<<
sub_comment
end
end
puts
"voting for these threads & comments.."
threads
.
each
do
|
c
|
users
.
each
do
|
user
|
user
.
vote
(
c
,
[
:up
,
:down
].
sample
)
end
end
end
end
comments
.
each
do
|
c
|
=begin
(threads + top_comments + additional_comments).each do |c|
users.each do |user|
users.each do |user|
user.vote(c, [:up, :down].sample)
user.vote(c, [:up, :down].sample)
end
end
end
end
=end
puts
"finished"
puts
"finished"
end
end
...
@@ -183,7 +184,7 @@ namespace :db do
...
@@ -183,7 +184,7 @@ namespace :db do
beginning_time
=
Time
.
now
beginning_time
=
Time
.
now
users
=
(
1
..
10
).
map
{
|
id
|
User
.
find_or_create_by
(
external_id:
id
.
to_s
)}
users
=
(
1
..
10
).
map
{
|
id
|
User
.
find_or_create_by
(
external_id:
id
.
to_s
)}
=begin
3.times do
3.times do
other_user = users[1..9].sample
other_user = users[1..9].sample
users.first.subscribe(other_user)
users.first.subscribe(other_user)
...
@@ -194,7 +195,7 @@ namespace :db do
...
@@ -194,7 +195,7 @@ namespace :db do
other_user = users.select{|u| u != user}.sample
other_user = users.select{|u| u != user}.sample
user.subscribe(other_user)
user.subscribe(other_user)
end
end
=end
generate_comments_for
(
"video_1"
)
generate_comments_for
(
"video_1"
)
generate_comments_for
(
"lab_1"
)
generate_comments_for
(
"lab_1"
)
generate_comments_for
(
"lab_2"
)
generate_comments_for
(
"lab_2"
)
...
...
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