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
3c17dd02
Commit
3c17dd02
authored
Jul 02, 2013
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new rake file
parent
96ab170b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
lib/tasks/deep_search.rake
+70
-0
No files found.
lib/tasks/deep_search.rake
0 → 100644
View file @
3c17dd02
require
'rest_client'
roots
=
{}
roots
[
'development'
]
=
"http://localhost:8000"
roots
[
'test'
]
=
"http://localhost:8000"
roots
[
'production'
]
=
"http://edx.org"
roots
[
'staging'
]
=
"http://stage.edx.org"
ROOT
=
roots
[
ENV
[
'SINATRA_ENV'
]]
namespace
:deep_search
do
task
:performance
=>
:environment
do
#USAGE
#SINATRA_ENV=development rake kpis:prolific
#or
#SINATRA_ENV=development bundle exec rake kpis:prolific
#create comment and thread bodies
bodies
=
[]
50
.
times
do
|
i
|
bodies
<<
(
0
...
8
).
map
{
(
'a'
..
'z'
).
to_a
[
rand
(
26
)]
}.
join
end
parents
=
CommentThread
.
limit
(
100
)
#now create comments and threads with hits
puts
"Manufacturing Threads"
100
.
times
do
|
j
|
(
1
..
5
).
to_a
.
sample
.
times
do
|
i
|
c
=
CommentThread
.
new
c
.
course_id
=
'sample course'
c
.
title
=
'sample title'
c
.
commentable_id
=
'sample commetable'
c
.
body
=
bodies
.
sample
c
.
author
=
1
c
.
save
end
end
puts
"Manufacturing Comments"
100
.
times
do
|
j
|
(
1
..
5
).
to_a
.
sample
.
times
do
|
i
|
c
=
Comment
.
new
c
.
course_id
=
'sample course'
c
.
body
=
bodies
.
sample
c
.
comment_thread_id
=
parents
.
sample
.
id
c
.
author
=
1
c
.
save
end
end
sort_keys
=
%w[date activity votes comments]
sort_order
=
"desc"
#set the sinatra env to test to avoid 401'ing
set
:environment
,
:test
start_time
=
Time
.
now
puts
"Starting test at
#{
start_time
}
"
1000
.
times
do
|
i
|
query_params
=
{
course_id:
"1"
,
sort_key:
sort_keys
.
sample
,
sort_order:
sort_order
,
page:
1
,
per_page:
5
,
text:
bodies
.
sample
}
RestClient
.
get
"
#{
PREFIX
}
/threads"
,
params:
query_params
end
end_time
=
Time
.
now
puts
"Ending test at
#{
start_time
}
"
puts
"Total Time:
#{
(
end_time
=
start_time
)
*
1
.
days
}
"
end
end
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