vrfs-775: tuning the new musician email

This commit is contained in:
Jonathan Kolyer 2013-11-26 08:40:06 -06:00
parent cde19cde56
commit c792b5216a
4 changed files with 44 additions and 9 deletions

View File

@ -1,16 +1,15 @@
<% provide(:title, 'New JamKazam Musicians in your Area') %>
<p>New JamKazam Musicians in your Area, <%= @user.first_name %>!</p>
<% link_style = "background-color:#ED3618; margin:0px 8px 0px 8px; border: solid 1px #F27861; outline: solid 2px #ED3618; padding:3px 10px; font-family:raleway; font-size:12px; font-weight:300; cursor:pointer; color:#FC9; text-decoration:none;" %>
<p>
<table bgcolor="#242323" cellpadding="3px" cellspacing="5px">
<% @new_nearby.each do |user| %>
<tr valign="top">
<td width="10%"><img src="http://192.168.2.14:3001/assets/shared/avatar_generic.png" /></td>
<td width="10%"><img src="http://<%= @host %>/assets/shared/avatar_generic.png" /></td>
<td width="20%"><font color="#ccc"><%= user.name %><br />
<%= user.location %></font><br />
<% user.musician_instruments.each do |inst| %>
<img src="http://<%= @host %>/assets/content/icon_instrument_<%= inst.id %>24.png" width="24" height="24" />
<% user.instruments.each do |inst| %>
<img src="http://<%= @host %>/assets/content/icon_instrument_<%= inst.icon_name %>24.png" width="24" height="24" />
<% end %>
</td>
<td width="70%"><font color="#ccc"><%= user.biography %></font><br /><br />

View File

@ -1,6 +1,35 @@
module JamRuby
class Instrument < ActiveRecord::Base
MAP_ICON_NAME = {
"accordion" => "accordion",
"acoustic guitar" => "acoustic",
"banjo" => "banjo",
"bass guitar" => "bass",
"cello" => "cello",
"clarinet" => "clarinet",
"computer" => "computer",
"default" => "default",
"drums" => "drums",
"electric guitar" => "guitar",
"euphonium" => "euphonium",
"flute" => "flute",
"french horn" => "frenchhorn",
"harmonica" => "harmonica",
"keyboard" => "keyboard",
"mandolin" => "mandolin",
"oboe" => "oboe",
"other" => "other",
"saxophone" => "saxophone",
"trombone" => "trombone",
"trumpet" => "trumpet",
"tuba" => "tuba",
"ukulele" => "ukelele",
"viola" => "viola",
"violin" => "violin",
"voice" => "vocals"
}
self.primary_key = 'id'
# users
@ -16,5 +45,9 @@ module JamRuby
return Instrument.where('instruments.popularity > 0').order('instruments.popularity DESC, instruments.description ASC')
end
def icon_name
MAP_ICON_NAME[self.id]
end
end
end

View File

@ -251,14 +251,17 @@ module JamRuby
end
def self.new_musicians(usr, since_date=Time.now - 1.week, max_count=50, radius=M_MILES_DEFAULT)
return unless block_given?
rel = User.musicians
.where(['created_at >= ? AND users.id != ?', since_date, usr.id])
.within(radius, :origin => [usr.lat, usr.lng])
.order('created_at DESC')
.limit(max_count)
objs = rel.all.to_a
yield(objs) if 0 < objs.count
if block_given?
yield(objs) if 0 < objs.count
else
return objs
end
end
end

View File

@ -990,10 +990,10 @@ module JamRuby
.limit(3)
end
def self.deliver_new_musician_notifications
def self.deliver_new_musician_notifications(since_date=Time.now-1.week)
self.geocoded_users.find_each do |usr|
Search.new_musicians(usr) do |new_nearby|
UserMailer.new_musicians(self, new_nearby).deliver
Search.new_musicians(usr, since_date) do |new_nearby|
UserMailer.new_musicians(usr, new_nearby).deliver
end
end
end