Mercurial > hg > soundsoftware-site
changeset 1100:0a4e71b11bd6 bibplugin_bibtex
prints number of found authors and users. New data structure for users and authors.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Thu, 29 Nov 2012 17:32:54 +0000 |
parents | c60d957342b0 |
children | 5392783ea417 |
files | vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb |
diffstat | 2 files changed, 18 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Thu Nov 29 14:42:16 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Thu Nov 29 17:32:54 2012 +0000 @@ -51,12 +51,13 @@ bibtex_parsed_authors = bib[0].authors bibtex_parsed_authors.each do |auth| - @suggested_authors[auth] = suggest_authors(auth) + @suggested_authors[auth] = suggest_authors(auth.last) end logger.error { "Suggested Authors: #{@suggested_authors}" } end + format.js end end @@ -227,23 +228,24 @@ render :layout => false end - # returns a list of authors - def suggest_authors(authorname) - firstname = authorname.first - lastname = authorname.last + # returns an hash with :authors and :users lists + def suggest_authors(lastname) # todo: improve name searching algorithm -- lf.20121127 authorships = Authorship.like(lastname).find(:all, :limit => 100) + logger.error { "Suggest Authors: Found #{authorships.count} Authorships " } - logger.error { "Authorships #{authorships}<-" } + suggested_authors = [] + suggested_authors = authorships.map { |a| a.author } unless authorships.empty? + suggested_authors.uniq! unless suggested_authors.empty? - unless authorships.empty? - authors = authorships.collect {|a| a.author} - authors.uniq! + users = User.like(lastname).find(:all) - # @users is a list of suggested users - # authors = authors.reject { |a| @users.include?(a.user) } - end + suggested_users = users.reject { |u| + suggested_authors.include?(u.author) + } + + { :authors => suggested_authors, :users => suggested_users } end
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb Thu Nov 29 14:42:16 2012 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb Thu Nov 29 17:32:54 2012 +0000 @@ -1,5 +1,9 @@ <p> Author: <%= h(author[0]) -%> + + #authors -- <%= h author[1][:authors].count %> + #users -- <%= h author[1][:users].count %> + </p>