changeset 1436:ee598c21c239 biblio_alt_search_auth

Changed query that was using group (breaking the development server): using uniq instead.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 10 Oct 2013 19:42:43 +0100
parents a9cfc6dcfb83
children 31de8828252a 8d721cac2925
files plugins/redmine_bibliography/app/controllers/publications_controller.rb
diffstat 1 files changed, 2 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Wed Oct 09 19:17:22 2013 +0100
+++ b/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Thu Oct 10 19:42:43 2013 +0100
@@ -200,10 +200,8 @@
     object_id = params[:object_id]
     @object_name = "publications[authorships_attributes][#{object_id}][search_results]"
 
-    # cc 20110909 -- revert to like instead of like_unique -- see #289
-    authorships_list = Authorship.like(params[:term]).group('author_id').find(:all, :limit => 100)
-
-    authors_list = authorships_list.collect do |x| x.author end
+    # todo: make sure query works with both pgres and mysql ~lf.20131010
+    authors_list = Author.joins(:authorships).where("LOWER(authorships.name_on_paper) LIKE LOWER(?)", "%#{params[:term]}%").uniq
 
     users_list = User.active.like(params[:term]).find(:all, :limit => 100)