hide phantom teachers that teach guitars
This commit is contained in:
parent
3aee4f8f28
commit
5f1536f809
|
|
@ -141,11 +141,13 @@ module JamRuby
|
|||
query = query.where("teaches_age_lower <= ? AND (CASE WHEN teaches_age_upper = 0 THEN true ELSE teaches_age_upper >= ? END)", student_age, student_age)
|
||||
end
|
||||
|
||||
# don't show phantom teachers that teach 'bass guitar', 'acoustic guitar', 'electric_guitar'
|
||||
query = query.where("((select count(checkgt.instrument_id) from teachers_instruments checkgt where checkgt.teacher_id = teachers.id AND checkgt.instrument_id IN ('bass guitar', 'acoustic guitar', 'electric guitar') ) = 0 AND phantom = true) OR phantom = false")
|
||||
|
||||
# order in this way: https://jamkazam.atlassian.net/browse/VRFS-4058
|
||||
# Real teachers who are marked as top.
|
||||
# Real teachers who are not marked as top.
|
||||
# Phantom teachers.
|
||||
|
||||
query = query.order("top_rated DESC, phantom ASC")
|
||||
|
||||
current_page = params[:page].nil? ? 1 : params[:page].to_i
|
||||
|
|
|
|||
|
|
@ -43,6 +43,26 @@ describe Teacher do
|
|||
query[2].should eq(teacher3.user)
|
||||
end
|
||||
|
||||
it "hide phantoms with guitar as instrument" do
|
||||
query = Teacher.index(nil, {})[:query]
|
||||
query.count.should eql 0
|
||||
|
||||
teacher3 = FactoryGirl.create(:teacher, ready_for_session_at: Time.now)
|
||||
teacher3.teachers_instruments.count.should eql 0
|
||||
teacher3.teachers_instruments << TeacherInstrument.new
|
||||
teacher3.teachers_instruments[0].teacher = teacher3
|
||||
teacher3.teachers_instruments[0].instrument = Instrument.find('electric guitar')
|
||||
teacher3.save!
|
||||
teacher3.user.email = 'phantom+dogpound@jamkazam.com'
|
||||
teacher3.user.save!
|
||||
teacher3.user.reload
|
||||
teacher3.user.phantom.should be_true
|
||||
|
||||
query = Teacher.index(nil, {})[:query]
|
||||
query.count.should eql 0
|
||||
end
|
||||
|
||||
|
||||
it "instruments" do
|
||||
teacher = FactoryGirl.create(:teacher, ready_for_session_at: Time.now)
|
||||
#teachers = Teacher.index(nil, {instruments: ['acoustic guitar']})[:query]
|
||||
|
|
|
|||
Loading…
Reference in New Issue