Skip to content
Snippets Groups Projects
Commit 0c31da69 authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

Merge branch 'search-service' into 'master'

Search service

Fixed search order by

See merge request !128
parents 49b47b6d 38ba8f61
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,11 @@ class SearchService ...@@ -18,7 +18,11 @@ class SearchService
private private
def build_search_query(params={}) def build_search_query(params={})
"SELECT @rid.asString(), last_modified, @class FROM ("+main_query(params)+") ORDER BY #{order_by(params[:order])}" order = order_by(params[:order])
ord_attr = order
ord_attr.slice!(' ASC')
ord_attr.slice!(' DESC')
"SELECT @rid.asString(), last_modified, @class, #{ord_attr} FROM ("+main_query(params)+") ORDER BY #{order}"
end end
def main_query(params={}) def main_query(params={})
...@@ -88,9 +92,9 @@ class SearchService ...@@ -88,9 +92,9 @@ class SearchService
def order_by(order) def order_by(order)
case order case order
when 'author' when 'author'
'author' 'author ASC'
when 'publicationasc' when 'publicationasc'
'published_at' 'published_at ASC'
when 'publicationdesc' when 'publicationdesc'
'published_at DESC' 'published_at DESC'
when 'title' when 'title'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment