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
14c29bf8
Commit
14c29bf8
authored
Aug 18, 2012
by
dementrock
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'benchmark' of github.com:rll/cs_comments_service into benchmark
parents
7b3fa9d4
c44af90b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
12 deletions
+8
-12
api/search.rb
+4
-4
models/comment_thread.rb
+4
-8
No files found.
api/search.rb
View file @
14c29bf8
...
...
@@ -32,14 +32,14 @@ get "#{APIPREFIX}/search/threads" do
results
=
CommentThread
.
perform_search
(
params
,
options
)
if
page
>
results
[
:total_pages
]
#TODO find a better way for this
results
=
CommentThread
.
perform_search
(
params
,
options
.
merge
(
page:
results
[
:total_pages
]
))
if
page
>
results
.
total_pages
#TODO find a better way for this
results
=
CommentThread
.
perform_search
(
params
,
options
.
merge
(
page:
results
.
total_pages
))
end
num_pages
=
results
[
:total_pages
]
num_pages
=
results
.
total_pages
page
=
[
num_pages
,
[
1
,
page
].
max
].
min
{
collection:
results
[
:result_ids
].
map
{
|
id
|
CommentThread
.
search_result_id_to_hash
(
id
,
recursive:
bool_recursive
)},
collection:
results
.
map
{
|
t
|
CommentThread
.
search_result_to_hash
(
t
,
recursive:
bool_recursive
)},
num_pages:
num_pages
,
page:
page
,
}.
to_json
...
...
models/comment_thread.rb
View file @
14c29bf8
...
...
@@ -75,14 +75,14 @@ class CommentThread < Content
c
end
def
self
.
search_result_
id_to_hash
(
id
,
params
=
{})
def
self
.
search_result_
to_hash
(
result
,
params
=
{})
comment_thread
=
self
.
find
(
result
.
id
)
highlight
=
result
.
highlight
||
{}
highlighted_body
=
(
highlight
[
:body
]
||
[]).
first
||
comment_thread
.
body
highlighted_title
=
(
highlight
[
:title
]
||
[]).
first
||
comment_thread
.
title
find
(
id
)
.
to_hash
(
params
).
merge
(
highlighted_body:
highlighted_body
,
highlighted_title:
highlighted_title
)
comment_thread
.
to_hash
(
params
).
merge
(
highlighted_body:
highlighted_body
,
highlighted_title:
highlighted_title
)
end
def
self
.
perform_search
(
params
,
options
=
{})
...
...
@@ -109,14 +109,10 @@ class CommentThread < Content
search
.
size
per_page
search
.
from
per_page
*
(
page
-
1
)
results
=
{
result_ids:
search
.
results
.
map
(
&
:id
),
total_pages:
search
.
results
.
total_pages
,
}
if
CommentService
.
config
[
:cache_enabled
]
Sinatra
::
Application
.
cache
.
set
(
memcached_key
,
results
,
CommentService
.
config
[
:cache_timeout
][
:threads_search
].
to_i
)
Sinatra
::
Application
.
cache
.
set
(
memcached_key
,
search
.
results
,
CommentService
.
config
[
:cache_timeout
][
:threads_search
].
to_i
)
end
results
search
.
results
end
def
activity_since
(
from_time
=
nil
)
...
...
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