VRFS-2795 fixing results display; generating same data

This commit is contained in:
Jonathan Kolyer 2015-04-04 02:54:58 +00:00
parent 325d3d2780
commit 1f432446f5
3 changed files with 60 additions and 26 deletions

View File

@ -32,6 +32,7 @@ context.JK.MusicianSearchFilter = class MusicianSearchFilter
afterShow: () =>
$('#musician-search-filter-results').hide()
$('#musician-search-filter-builder').show()
this.renderSearchFilter()
loadSearchFilter: (sFilter) =>
@ -181,16 +182,16 @@ context.JK.MusicianSearchFilter = class MusicianSearchFilter
_formatLocation = (musician) ->
if musician.city and musician.state
musician.city + ', ' + musician.regionname
musician.city + ', ' + musician.state
else if musician.city
musician.city
else if musician.state
else if musician.regionname
musician.regionname
else
'Location Unavailable'
didSearch: (response) =>
console.log("response = ", JSON.stringify(response))
# console.log("response = ", JSON.stringify(response))
$('#musician-search-filter-builder').hide()
$('#musician-search-filter-results').show()
@searchResults = response
@ -207,14 +208,12 @@ context.JK.MusicianSearchFilter = class MusicianSearchFilter
renderMusicians: () =>
ii = undefined
len = undefined
mTemplate = $('#template-search-musician-row').html()
aTemplate = $('#template-search-musician-action-btns').html()
mVals = undefined
musician = undefined
renderings = ''
instr_logos = undefined
instr = undefined
follows = undefined
followVals = undefined
aFollow = undefined
@ -231,11 +230,9 @@ context.JK.MusicianSearchFilter = class MusicianSearchFilter
jj = 0
ilen = musician['instruments'].length
while jj < ilen
toolTip = ''
if musician['instruments'][jj].instrument_id in @instrument_logo_map
instr = @instrument_logo_map[musician['instruments'][jj].instrument_id].asset
toolTip = musician['instruments'][jj].instrument_id
instr_logos += '<img src="' + instr + '" title="' + toolTip + '"/>'
instr_id = musician['instruments'][jj].instrument_id
if instr_img = @instrument_logo_map[instr_id]
instr_logos += '<img height="24" width="24" src="' + instr_img.asset + '" title="' + instr_id + '"/>'
jj++
actionVals =
profile_url: '/client#/profile/' + musician.id

View File

@ -77,9 +77,12 @@ script#template-search-musician-row type="text/template"
.left.musician-info
.first-row data-hint="top-row"
.musician-profile
.result-name musician_name
.result-location musician_location
#result_instruments.instruments.nowrap.mt10 instruments
.result-name
| {musician_name}
.result-location
| {musician_location}
#result_instruments.instruments.nowrap.mt10
| {instruments}
.musician-stats
span.friend-count
| {friend_count}
@ -97,13 +100,14 @@ script#template-search-musician-row type="text/template"
.left.musician-latency
.latency-help
| Your latency
br>/
br /
| to {musician_first_name} is:
.latency-holder
| {latency_badge}
br clear="both" /
.button-row data-hint="button-row"
.biography biography
.biography
| {biography}
.result-list-button-wrapper data-musician-id="{musician_id}"
| {musician_action_template}
br clear="both" /

View File

@ -34,10 +34,13 @@ namespace :db do
end
task populate: :environment do
make_users(10) if 14 > User.count
make_users(30) if 14 > User.count
make_friends
make_followings
make_bands
make_band_members
# make_music_sessions_history
# make_music_sessions_user_history
make_recording
end
@ -90,16 +93,18 @@ end
def make_music_sessions_history
users = User.all.map(&:id)
bands = Band.all.map(&:id)
genres = Genre.all.map(&:description)
50.times do |nn|
genres = Genre.all
20.times do |nn|
obj = MusicSession.new
obj.music_session_id = rand(100000000).to_s
obj.description = Faker::Lorem.paragraph
obj.description = 'description goes here' # Faker::Lorem.paragraph avoid accidental profanity
obj.user_id = users[rand(users.count)]
obj.band_id = bands[rand(bands.count)]
obj.created_at = Time.now - rand(1.month.seconds)
obj.session_removed_at = obj.created_at + (rand(3)+1).hour
obj.genres = genres.shuffle[0..rand(4)].join(' | ')
obj.genre = genres.sample
obj.legal_terms = true
obj.name = Faker::Lorem.sentence
obj.save!
end
end
@ -171,20 +176,45 @@ end
def make_users(num=99)
admin = User.create!(first_name: Faker::Name.name,
last_name: Faker::Name.name,
email: "example@railstutorial.org",
email: Faker::Internet.safe_email,
password: "foobar",
password_confirmation: "foobar",
terms_of_service: true)
admin.toggle!(:admin)
instruments = Instrument.all
num.times do |n|
email = "example-#{n+1}@railstutorial.org"
password = "password"
User.create!(first_name: Faker::Name.name,
uu = User.create!(first_name: Faker::Name.name,
last_name: Faker::Name.name,
terms_of_service: true,
email: email,
email: Faker::Internet.email,
password: password,
city: Faker::Address.city,
state: Faker::Address.state_abbr,
country: 'US',
password_confirmation: password)
uu.musician = true
num_instrument = rand(4) + 1
user_instruments = instruments.sample(num_instrument)
num_instrument.times do |mm|
musician_instrument = MusicianInstrument.new
musician_instrument.user = uu
musician_instrument.instrument = user_instruments[mm]
musician_instrument.proficiency_level = rand(3) + 1
musician_instrument.priority = rand(num_instrument)
uu.musician_instruments << musician_instrument
end
uu.save!
yn = true
while yn
begin
uu.biography = Faker::Lorem.sentence
uu.save!
yn = false
rescue
end
end
end
end
@ -209,8 +239,11 @@ def make_followings
users = User.all
users.each do |uu|
users[0..rand(users.count)].shuffle.each do |uuu|
uuu.followings << uu unless 0 < Follow.where(:followable_id => uu.id, :user_id => uuu.id).count
uu.followings << uuu unless 0 < Follow.where(:followable_id => uuu.id, :user_id => uu.id).count if rand(3)==0
next if 0 < Follow.where(:followable_id => uu.id, :user_id => uuu.id).count
follow = Follow.new
follow.followable = uu
follow.user = uuu
follow.save
end
end
end