Permalink
Browse files

cleanup ontologies and ontology terms controllers

  • Loading branch information...
1 parent c58fb29 commit ee267df55c2398df166f3191a51be2cb22f29d65 @jgeiger committed Jun 21, 2011
@@ -44,13 +44,13 @@ def update
def show
page = (params[:page].to_i > 0) ? params[:page].to_i : 1
- @q = params[:query]
- @ontologies = OntologyTerm.where(:ontology_id => @ontology.id).where(:name => /^#{@q}/i).order_by([:name, :asc]).page(page)
+ @query = params[:query]
+ @ontology_terms = OntologyTerm.where(ncbo_id: @ontology.ncbo_id, term_name: /^#{@query}/i).order_by([:term_name, :asc]).page(page)
respond_to do |format|
format.html {}
format.js {
- render(:partial => "ontology_term_list.html.haml")
+ render(:partial => "ontologies/ontology_term_list.html.haml")
}
end
@@ -15,18 +15,17 @@ def index
end
def show
- @ontology_term = OntologyTerm.first(:conditions => {:term_id => CGI::unescape(params[:id])})
- annotation_type = params['annotation_type']
- page = (params[:page].to_i > 0) ? params[:page].to_i : 1
- raise Mongoid::Errors::DocumentNotFound if !@ontology_term
+ ncbo_id, term_id = CGI::unescape(params[:id]).split('|')
+ @ontology_term = OntologyTerm.where(ncbo_id: ncbo_id, term_id: term_id).first
+ raise Mongoid::Errors::DocumentNotFound if !@ontology_term
respond_to do |format|
format.html { }
format.js {}
end
rescue Mongoid::Errors::DocumentNotFound
- redirect_to(ontology_terms_url, warning: "That ontology term does not exist.")
+ redirect_to(ontology_terms_url, error: "That ontology term does not exist.")
end
end
@@ -61,12 +61,16 @@ def audited_annotation_percentage
end
end
- # def valid_annotation_count
- # Annotation.count(:conditions => {:ontology_term_id => self.id, :verified => true})
- # end
- #
- # def audited_annotation_count
- # Annotation.count(:conditions => {:ontology_term_id => self.id, :status => 'audited'})
- # end
+ def annotations_count
+ Annotation.where(ontology_term_id: self.term_id, ncbo_id: self.ncbo_id).count
+ end
+
+ def valid_annotation_count
+ Annotation.where(ontology_term_id: self.term_id, ncbo_id: self.ncbo_id, verified: true).count
+ end
+
+ def audited_annotation_count
+ Annotation.where(ontology_term_id: self.term_id, ncbo_id: self.ncbo_id, :status => 'audited').count
+ end
end
@@ -1,14 +1,11 @@
%tr{:class => "#{cycle('row-odd', 'row-even')}"}
%td{:valign => "top", :width => "40%"}
- = link_to(ontology_term.name, ontology_term_url(ontology_term))
- = ncbo_ontology_link(ontology_term.ncbo_id, ontology_term.term_id)
- %td{:valign => "top"}
- = has_annotations(ontology_term.annotations_count)
+ = link_to(ontology_term.term_name, ontology_term_url(ontology_term))
- if admin?
%td{:valign => "top"}
= annotation_percentage(ontology_term.annotations_count, ontology_term.valid_annotation_percentage)
%td{:valign => "top"}
= annotation_percentage(ontology_term.annotations_count, ontology_term.audited_annotation_percentage)
- if (ontology_term.annotations_count > 0) && (ontology_term.audited_annotation_percentage < 100)
%br
- = link_to("Audit", audit_annotations_url(:query => ontology_term.name, :status => "Unaudited", :ddown => ontology_term.ontology.ncbo_id))
+ = link_to("Audit", audit_annotations_url(:query => ontology_term.term_name, :status => "Unaudited", :ncbo_id => ontology_term.ncbo_id))
@@ -11,14 +11,12 @@
%table{:width => "100%", :border => "0", :cellpadding => "0", :cellspacing => "2"}
%thead
%tr.row-header
- %td{:width => "40%"}
+ %td{:width => "60%"}
Ontology term
- %td{:width => "20%"}
- Annotation count
- if admin?
%td{:width => "20%"}
Valid
%td{:width => "20%"}
Audited
%tbody
- = render(:partial => "ontology_term.html.haml", :collection => @ontology_terms)
+ = render(:partial => "ontologies/ontology_term.html.haml", :collection => @ontology_terms)
@@ -7,4 +7,4 @@
Filter on name:
= text_field_tag(:query, params['query'], :autocomplete => 'off')
.dataTable
- = render(:partial => "ontology_term_list.html.haml")
+ = render(:partial => "ontologies/ontology_term_list.html.haml")
@@ -1,5 +1,4 @@
-= page_title("Ontology term: #{@ontology_term.name} (#{@ontology_term.specific_term_id})")
+= page_title("Ontology term: #{@ontology_term.term_name} (#{@ontology_term.specific_term_id})")
%br
%p
- == Ontology: #{link_to(@ontology_term.ontology.name, ontology_url(@ontology_term.ontology))}
= link_to('Back', ontology_terms_url)

0 comments on commit ee267df

Please sign in to comment.