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
52f44f99
Commit
52f44f99
authored
Jun 11, 2013
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deep search testing 1
parent
5d644862
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
models/comment_thread.rb
+4
-2
spec/api/query_spec.rb
+28
-0
No files found.
models/comment_thread.rb
View file @
52f44f99
...
...
@@ -118,8 +118,7 @@ class CommentThread < Content
#thread ids and the original thread search) and merge the results, uniqifying the results in the process.
#so first, find the comment threads associated with comments that hit the query
search
=
Tire
::
Search
::
Search
.
new
'comment_threads'
search
.
query
{
|
query
|
query
.
text
:_all
,
params
[
"text"
]}
if
params
[
"text"
]
search
.
highlight
({
title:
{
number_of_fragments:
0
}
}
,
{
body:
{
number_of_fragments:
0
}
},
options:
{
tag:
"<highlight>"
})
...
...
@@ -145,6 +144,9 @@ class CommentThread < Content
end
results
=
search
.
results
puts
"PHASE I RESULTS:
#{
results
.
collect
{
|
r
|
r
[
'id'
]
}
}"
#if this is a search query, then also search the comments and harvest the matching comments
if
params
[
"text"
]
...
...
spec/api/query_spec.rb
0 → 100644
View file @
52f44f99
require
'spec_helper'
describe
"app"
do
describe
"search"
do
describe
"GET /api/v1/search/threads"
do
it
"returns thread with query match"
do
user
=
User
.
find
1
if
not
user
user
=
create_test_user
(
1
)
end
commentable
=
Commentable
.
new
(
"question_1"
)
thread
=
CommentThread
.
new
(
title:
"Test title"
,
body:
"otter"
,
course_id:
"1"
,
commentable_id:
commentable
.
id
)
thread
.
author
=
user
thread
.
save!
puts
"thread id is
#{
thread
.
id
}
"
get
"/api/v1/search/threads"
,
text:
"otter"
last_response
.
should
be_ok
threads
=
parse
(
last_response
.
body
)[
'collection'
]
puts
"threads:
#{
threads
.
collect
{
|
t
|
t
[
'id'
]
}
}"
threads
.
select
{
|
t
|
t
[
"id"
].
to_s
==
thread
.
id
.
to_s
}.
first
.
should_not
be_nil
end
end
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