Adjusting ranking method
This commit is contained in:
parent
45bac6cae4
commit
ef46bf6a98
|
@ -90,42 +90,22 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def member_status
|
def member_status
|
||||||
case self.member_level.to_i
|
member_status_calculation[:rank]
|
||||||
when 0
|
|
||||||
if self.payments.count > 0 then
|
|
||||||
2
|
|
||||||
else
|
|
||||||
-1
|
|
||||||
end
|
|
||||||
when 1
|
|
||||||
1
|
|
||||||
when 10..24
|
|
||||||
10
|
|
||||||
when 25..999
|
|
||||||
if self.payments.count > 0 then
|
|
||||||
if self.payments.last.date < (DateTime.now - 45.days)
|
|
||||||
3
|
|
||||||
else
|
|
||||||
case self.member_level.to_i
|
|
||||||
when 25..49
|
|
||||||
25
|
|
||||||
when 50..99
|
|
||||||
50
|
|
||||||
when 100..999
|
|
||||||
100
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def member_status_symbol
|
def member_status_symbol
|
||||||
|
results = member_status_calculation
|
||||||
|
return "<img src='#{results[:icon]}#{results[:flair]}-coin.png' title='#{results[:message]}' />"
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def member_status_calcuation
|
||||||
# Begin output buffer
|
# Begin output buffer
|
||||||
message = ""
|
message = ""
|
||||||
icon = ""
|
icon = ""
|
||||||
flair = ""
|
flair = ""
|
||||||
|
rank = 0
|
||||||
|
|
||||||
# First status item is level
|
# First status item is level
|
||||||
case self.member_level.to_i
|
case self.member_level.to_i
|
||||||
|
@ -133,22 +113,28 @@ class User < ActiveRecord::Base
|
||||||
if self.payments.count > 0 then
|
if self.payments.count > 0 then
|
||||||
message = "Former Member (#{(DateTime.now - self.payments.last.date).to_i} days ago)"
|
message = "Former Member (#{(DateTime.now - self.payments.last.date).to_i} days ago)"
|
||||||
icon = :timeout
|
icon = :timeout
|
||||||
|
rank = 1
|
||||||
else
|
else
|
||||||
message = "Not a Member"
|
message = "Not a Member"
|
||||||
icon = :no
|
icon = :no
|
||||||
|
rank = 0
|
||||||
end
|
end
|
||||||
when 10..24
|
when 10..24
|
||||||
message = "Volunteer"
|
message = "Volunteer"
|
||||||
icon = :heart
|
icon = :heart
|
||||||
|
rank = 100
|
||||||
when 25..49
|
when 25..49
|
||||||
message = member_level_string
|
message = member_level_string
|
||||||
icon = :copper
|
icon = :copper
|
||||||
|
rank = 250
|
||||||
when 50..99
|
when 50..99
|
||||||
message = member_level_string
|
message = member_level_string
|
||||||
icon = :silver
|
icon = :silver
|
||||||
|
rank = 500
|
||||||
when 100..999
|
when 100..999
|
||||||
message = member_level_string
|
message = member_level_string
|
||||||
icon = :gold
|
icon = :gold
|
||||||
|
rank = 1000
|
||||||
end
|
end
|
||||||
|
|
||||||
# Second status item is payment status
|
# Second status item is payment status
|
||||||
|
@ -161,15 +147,17 @@ class User < ActiveRecord::Base
|
||||||
flair = "-paid"
|
flair = "-paid"
|
||||||
else
|
else
|
||||||
message = "Last Payment (#{(DateTime.now - self.payments.last.date).to_i} days ago)"
|
message = "Last Payment (#{(DateTime.now - self.payments.last.date).to_i} days ago)"
|
||||||
|
rank = rank/10
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
message = "No Payments Recorded"
|
||||||
|
rank = rank/10
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return "<img src='#{icon}#{flair}-coin.png' title='#{message}' />"
|
return [:message => message, :icon => icon, :flair => flair, :rank => rank]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def send_new_user_email
|
def send_new_user_email
|
||||||
Rails.logger.info UserMailer.new_user_email(self).deliver
|
Rails.logger.info UserMailer.new_user_email(self).deliver
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user