Browse files

Tree view for scientific results, no disambiguation for duplicate res…

…ults, and all results have more information (search presentation); resolves EOLINFRASTRUCTURE-1666

git-svn-id: file:///data/subversion/eol/trunk@1811 78829999-583a-0410-bd01-8a9b849fd409
  • Loading branch information...
1 parent 7552396 commit aa3e152bf7c0d27b6679e5aa898a61d691c1abe2 jrice committed Mar 31, 2010
View
17 app/views/taxa/_search_results_table.html.haml
@@ -21,23 +21,16 @@
%a{ :href => url_for(:action => 'search_clicked', :id => result['id']) }
%img{ :title => strip_tags(result['best_matched_scientific_name']), :src => result['top_image'].smart_medium_thumb, :alt => strip_tags(result['best_matched_scientific_name']) }
%td{ :class => column_class }
- - if result['duplicate']
- .ancestor= result['ancestor_common']
- .parent= result['parent_common']
- %div{:class => "result#{' duplicate' if result['duplicate']}"}
+ %div{:class => "result"}
= link_to hh(result['best_matched_common_name']), {:action => 'search_clicked', :id => result['id']}, :method=>:post
= result['common_shown_as']
- - if result['duplicate']
- %span.recognized_by= "Taxon recognized by #{result['recognized_by']}"
%td{ :class => column_class }
- - if result['duplicate']
- .ancestor= result['ancestor_scientific']
- .parent= result['parent_scientific']
- %div{:class => "result#{' duplicate' if result['duplicate']}"}
+ .ancestor= result['ancestor_scientific']
+ .parent= result['parent_scientific']
+ %div{:class => "result duplicate"}
= link_to hh(result['best_matched_scientific_name']), {:action => 'search_clicked', :id => result['id']}, :method=>:post
= result['scientific_shown_as']
- - if result['duplicate']
- %span.recognized_by= "Taxon recognized by #{result['recognized_by']}"
+ %span.recognized_by= "Taxon recognized by #{result['recognized_by']}"
-# end results.each
= will_paginate(results)
- # /search_results
View
16 lib/eol/search_results_collection.rb
@@ -34,7 +34,7 @@ def initialize(results, options = {})
# time being, we always are. In the future, this will want to be abstracted out, so that we inherit all the common
# behaviour and add this behaviour if it's a TC-based search:
update_results_with_current_data
- handle_apparent_duplicates
+ add_mini_tree_and_attribution
adapt_results_for_view
end
@@ -115,7 +115,7 @@ def get_current_data_from_taxon_concept_id(id, result)
return {'preferred_scientific_name' => (tc.scientific_name(@session_hierarchy) ||
result["preferred_scientific_name"] || ''),
'preferred_common_name' => (tc.common_name(@session_hierarchy) || result["preferred_common_name"] || ''),
- # There are some "expensive" operations we only want to do on duplicates, so store the TC here:
+ # There are some "expensive" operations done later, so store tc here:
'taxon_concept' => tc }
# Really, we don't want to save these exceptions, since what good is a search result if the TC is missing?
# However, tests sometimes create situations where this is possible and not "wrong", (creating TCs is expensive!) so:
@@ -166,19 +166,15 @@ def repair_missing_match_fields(result)
result[@best_match_field_name] ||= ''
end
- def handle_apparent_duplicates
+ def add_mini_tree_and_attribution
return nil unless @results
- best_names = @results.map {|r| r[@best_match_field_name]}
@results.each do |result|
- if best_names.find_all {|r| r == result[@best_match_field_name]}.length > 1
- handle_duplicate(result) unless ENV['RAILS_ENV'] == 'production'
- end
+ add_tree_and_arttribution_fields(result) unless ENV['RAILS_ENV'] == 'production'
end
end
private
- def handle_duplicate(result)
- result["duplicate"] = true
+ def add_tree_and_arttribution_fields(result)
tc = result["taxon_concept"]
if tc
result["recognized_by"] = result["taxon_concept"].entry.hierarchy.label
@@ -187,10 +183,8 @@ def handle_duplicate(result)
ancestor = ancestors[-3]
if parent and parent.class == TaxonConcept
result["parent_scientific"] = parent.scientific_name
- result["parent_common"] = parent.common_name
if ancestor and ancestor.class == TaxonConcept
result["ancestor_scientific"] = ancestor.scientific_name
- result["ancestor_common"] = ancestor.common_name
end
end
else
View
2 spec/controllers/taxa_controller_spec.rb
@@ -34,13 +34,11 @@ def hijack_search_for_tiger
it 'should show the parent taxon_concept of the duplicates' do
hijack_search_for_tiger
- response.should have_tag('div.parent', :text => @parent_concept.common_name)
response.should have_tag('div.parent', :text => @parent_concept.scientific_name)
end
it 'should show the ancestor (grandparent) taxon_concept of the duplicates' do
hijack_search_for_tiger
- response.should have_tag('div.ancestor', :text => @ancestor_concept.common_name)
response.should have_tag('div.ancestor', :text => @ancestor_concept.scientific_name)
end
View
7 spec/lib/eol_search_results_collection_spec.rb
@@ -40,11 +40,6 @@
@tc_result["preferred_common_name"].should == @new_common_name
end
- it 'should mark duplicates' do
- @tc_result["duplicate"].should be_true
- @dup_tc_result["duplicate"].should be_true
- end
-
it 'should show whom duplicate entries are recognized by' do
@tc_result["recognized_by"].should == @taxon_concept.entry.hierarchy.label
@dup_tc_result["recognized_by"].should == @duplicate_taxon_concept.entry.hierarchy.label
@@ -54,8 +49,6 @@
ancestors = @tc_result['taxon_concept'].ancestors
parent_concept = ancestors[-2]
ancestor_concept = ancestors[-3]
- @tc_result["parent_common"].should == parent_concept.common_name
- @tc_result["ancestor_common"].should == ancestor_concept.common_name
@tc_result["parent_scientific"].should == parent_concept.scientific_name
@tc_result["ancestor_scientific"].should == ancestor_concept.scientific_name
end

0 comments on commit aa3e152

Please sign in to comment.