@@ -87,7 +87,7 @@ class Exercise < ActiveRecord::Base
8787 # validates :current_version, presence: true
8888
8989 #~ Pagination ...............................................................
90- max_paginates_per 50
90+ max_paginates_per 40
9191
9292 Q_MC = 1
9393 Q_CODING = 2
@@ -130,19 +130,16 @@ def self.search(terms, user = nil)
130130 end
131131 if user
132132 visible = Exercise . visible_to_user ( user )
133- result = visible . tagged_with ( terms , any : true , wild : true , on : :tags ) +
134- visible . tagged_with ( terms , any : true , wild : true , on : :languages ) +
135- visible . tagged_with ( terms , any : true , wild : true , on : :styles ) +
136- visible . where ( '(name regexp (?)) or (exercises.id in (?))' , r , ids )
137- return result . uniq
138133 else
139134 visible = Exercise . publicly_visible
140- result = visible . tagged_with ( terms , any : true , wild : true , on : :tags ) +
141- visible . tagged_with ( terms , any : true , wild : true , on : :languages ) +
142- visible . tagged_with ( terms , any : true , wild : true , on : :styles ) +
143- visible . where ( '(name regexp (?)) or (exercises.id in (?))' , r , ids )
144- return result . uniq
145135 end
136+
137+ result = visible . tagged_with ( terms , any : true , wild : true , on : :tags )
138+ . union ( visible . tagged_with ( terms , any : true , wild : true , on : :languages ) )
139+ . union ( visible . tagged_with ( terms , any : true , wild : true , on : :styles ) )
140+ . union ( visible . where ( '(name regexp (?)) or (exercises.id in (?))' , r , ids ) )
141+ . distinct
142+ return result
146143 end
147144
148145
0 commit comments