#1938 remove duplicates, remember &random and &raw params
This commit is contained in:
@@ -74,7 +74,11 @@ module PostSets
|
|||||||
temp = []
|
temp = []
|
||||||
limit = [per_page, count].min
|
limit = [per_page, count].min
|
||||||
limit.times do
|
limit.times do
|
||||||
post = ::Post.tag_match(tag_string).offset(rand(count)).first
|
q = ::Post.tag_match(tag_string)
|
||||||
|
unless temp.empty?
|
||||||
|
q = q.where("id not in (?)", temp.map(&:id))
|
||||||
|
end
|
||||||
|
post = q.offset(rand(count - temp.length)).first
|
||||||
if post
|
if post
|
||||||
temp << post
|
temp << post
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,6 +7,12 @@
|
|||||||
<h1>Search</h1>
|
<h1>Search</h1>
|
||||||
<%= form_tag(path, :method => "get") do %>
|
<%= form_tag(path, :method => "get") do %>
|
||||||
<%= text_field_tag("tags", tags, :size => 20) %>
|
<%= text_field_tag("tags", tags, :size => 20) %>
|
||||||
|
<% if params[:raw] %>
|
||||||
|
<%= hidden_field_tag :raw, params[:raw] %>
|
||||||
|
<% end %>
|
||||||
|
<% if params[:random] %>
|
||||||
|
<%= hidden_field_tag :random, params[:random] %>
|
||||||
|
<% end %>
|
||||||
<%= submit_tag "Go", :name => nil %>
|
<%= submit_tag "Go", :name => nil %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user