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
07901bf8
Commit
07901bf8
authored
Feb 18, 2013
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search working, using course_id index to cut down on corpus, need to test pagination
parent
9b3085e0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
37 deletions
+2
-37
models/comment_thread.rb
+2
-37
No files found.
models/comment_thread.rb
View file @
07901bf8
...
...
@@ -93,6 +93,7 @@ class CommentThread < Content
end
def
self
.
perform_search
(
params
,
options
=
{})
page
=
[
1
,
options
[
:page
]
||
1
].
max
per_page
=
options
[
:per_page
]
||
20
sort_key
=
options
[
:sort_key
]
...
...
@@ -130,68 +131,37 @@ class CommentThread < Content
search
.
filter
:or
,
[
{
:not
=>
{
:exists
=>
{
:field
=>
:group_id
}}},
{
:term
=>
{
:group_id
=>
params
[
"group_id"
]}}
<<<<<<<
Updated
upstream
=======
>>>>>>>
Stashed
changes
]
end
search
.
sort
{
|
sort
|
sort
.
by
sort_key
,
sort_order
}
if
sort_key
&&
sort_order
#TODO should have search option 'auto sort or sth'
<<<<<<<
Updated
upstream
search
.
size
per_page
search
.
from
per_page
*
(
page
-
1
)
=======
#again, b/c there is no relationship in ordinality, we cannot paginate if it's a text query
if
not
params
[
"text"
]
search
.
size
per_page
search
.
from
per_page
*
(
page
-
1
)
end
>>>>>>>
Stashed
changes
results
=
search
.
results
#if this is a search query, then also search the comments and harvest the matching comments
if
params
[
"text"
]
<<<<<<<
Updated
upstream
#temp
params
=
{}
params
[
"text"
]
=
"test"
#end temp
search
=
Tire
::
Search
::
Search
.
new
'comments'
search
.
query
{
|
query
|
query
.
text
:_all
,
params
[
"text"
]}
if
params
[
"text"
]
search
.
size
per_page
search
.
from
per_page
*
(
page
-
1
)
=======
search
=
Tire
::
Search
::
Search
.
new
'comments'
search
.
query
{
|
query
|
query
.
text
:_all
,
params
[
"text"
]}
if
params
[
"text"
]
search
.
filter
(
:term
,
commentable_id:
params
[
"commentable_id"
])
if
params
[
"commentable_id"
]
search
.
filter
(
:terms
,
commentable_id:
params
[
"commentable_ids"
])
if
params
[
"commentable_ids"
]
search
.
filter
(
:term
,
course_id:
params
[
"course_id"
])
if
params
[
"course_id"
]
#unforutnately, we cannot paginate here, b/c we don't know how the ordinality is totally
#unrelated to that of threads
>>>>>>>
Stashed
changes
c_results
=
search
.
results
comment_ids
=
c_results
.
collect
{
|
c
|
c
.
id
}.
uniq
comments
=
Comment
.
where
(
:id
.
in
=>
comment_ids
)
<<<<<<<
Updated
upstream
thread_ids
=
comments
.
collect
{
|
c
|
c
.
comment_thread_id
}
#now run one more search to harvest the threads and filter by group
search
=
Tire
::
Search
::
Search
.
new
'comment_threads'
search
.
filter
(
:term
,
:thread_id
=>
thread_ids
)
=======
thread_ids
=
comments
.
collect
{
|
c
|
c
.
comment_thread_id
}.
uniq
original_thread_ids
=
results
.
collect
{
|
r
|
r
.
id
}
#now add the original search thread ids
...
...
@@ -204,9 +174,9 @@ class CommentThread < Content
search
.
filter
(
:terms
,
:thread_id
=>
thread_ids
)
search
.
filter
(
:terms
,
commentable_id:
params
[
"commentable_ids"
])
if
params
[
"commentable_ids"
]
search
.
filter
(
:term
,
course_id:
params
[
"course_id"
])
if
params
[
"course_id"
]
search
.
size
per_page
search
.
from
per_page
*
(
page
-
1
)
>>>>>>>
Stashed
changes
if
params
[
"group_id"
]
...
...
@@ -217,13 +187,8 @@ class CommentThread < Content
]
end
<<<<<<<
Updated
upstream
results
+=
search
.
results
=======
search
.
sort
{
|
sort
|
sort
.
by
sort_key
,
sort_order
}
if
sort_key
&&
sort_order
results
=
search
.
results
>>>>>>>
Stashed
changes
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