Skip to content

Commit

Permalink
Made search results and autocomplete only come from "current" versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
zk committed Sep 26, 2011
1 parent a6d4aa0 commit 5477bdc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/controllers/main_controller.rb
Expand Up @@ -122,10 +122,16 @@ def search


@functions = Function.search(q, :page => params[:page], :per_page => 16, :match_mode => :extended, :field_weights => {:name => 10,:doc => 1}) @functions = Function.search(q, :page => params[:page], :per_page => 16, :match_mode => :extended, :field_weights => {:name => 10,:doc => 1})




@functions = @functions[0..24] @functions = @functions[0..24]


end end


@functions = @functions.find_all { |f|
f.library.current
}

if params[:feeling_lucky] and @functions.size > 0 if params[:feeling_lucky] and @functions.size > 0
func = @functions[0] func = @functions[0]
redirect_to "/#{func.library}/#{func.ns}/#{CGI::escape(func.name)}" redirect_to "/#{func.library}/#{func.ns}/#{CGI::escape(func.name)}"
Expand Down Expand Up @@ -330,7 +336,11 @@ def search_autocomplete
if @exact_matches if @exact_matches
@functions = (@exact_matches + @functions).uniq @functions = (@exact_matches + @functions).uniq
end end


@functions = @functions.find_all { |f|
f.library.current
}

if @functions.size > 10 if @functions.size > 10
@functions = @functions[0, 10] @functions = @functions[0, 10]
end end
Expand Down

0 comments on commit 5477bdc

Please sign in to comment.