Permalink
Browse files

Fixed incorrect missing examples count as a result of schema change.

  • Loading branch information...
1 parent 25190e0 commit d262bc0e54615299834a4a50c80808e70a134e15 @zk committed Oct 11, 2010
Showing with 8 additions and 3 deletions.
  1. +1 −1 app/controllers/management_controller.rb
  2. +7 −2 app/views/_missing_examples.html.erb
@@ -4,7 +4,7 @@ class ManagementController < ApplicationController
require 'chronic'
def index
- @lib = Library.find(:first, :conditions => {:name => params[:lib]})
+ @lib = Library.find(:first, :conditions => {:url_friendly_name => params[:lib]})
@recently_updated = find_recently_updated(100, @lib.name)
end
@@ -2,9 +2,14 @@
#total_count = Function.find_by_sql(["select count(id) from functions where library = ?", @lib.name])[0]["count(id)"].to_i
total_count = Function.count(:all,
:include => [:namespace, {:namespace => :library}],
- :conditions => {:namespaces => {:libraries => {:name => @lib.name}}})
+ :conditions => {:namespaces => {:libraries => {:name => @lib.name, :version => @lib.version}}})
-missing_examples = Function.find_by_sql(["select distinct name, id from functions where (id) not in (select function_id from examples) order by name"])
+missing_examples = Function.find(:all,
+ :select=>"functions.*",
+ :joins=>"LEFT OUTER JOIN examples ON functions.id = examples.function_id LEFT OUTER JOIN namespaces on functions.namespace_id = namespaces.id LEFT OUTER JOIN libraries on namespaces.library_id = libraries.id",
+ :conditions => ["examples.id is NULL and libraries.name = ? and libraries.version = ?", @lib.name, @lib.version],
+ :order => :name)
+
missing_examples_count = missing_examples.size
functions_with_examples_count = total_count - missing_examples_count

0 comments on commit d262bc0

Please sign in to comment.