Skip to content

Commit

Permalink
list guild firsts in the mails first. bwahahahaha. this isn't me show…
Browse files Browse the repository at this point in the history
…ing off at ALL.
  • Loading branch information
Tom Insam committed Dec 11, 2010
1 parent 8321324 commit 486d683
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/guild_controller.rb
Expand Up @@ -35,10 +35,14 @@ def feed
def summary
@items = @guild.guild_achievements.where( [ 'created_at >= ?', Date.today - 1.week ] )
@people = @items.group_by{|i| i.character }.sort_by{|character, items| [ character.achpoints * -1, character.rank ] }
@people.each{|person,items|
# replace items in place
items[0..items.length] = items.sort_by{|i| [ (i.first ? 0 : 1), i.achievement_id * -1 ] }
}
@level_80 = @guild.characters.count(:conditions => { :level => 80 } )
@total = @guild.characters.count
@levels = @items.select{|i| i.achievement.name.match(/^Level \d+/) }.map{|i| [ i.character, i.achievement.name.downcase ] }.sort_by{|char, level| level }.reverse.uniq_by{|character, level| character }
render :layout => false, :template => "guild_mailer/weekly_summary.text.html.rhtml", :content_type => "text/html"
render :layout => false, :template => "guild_mailer/weekly_summary.html.rhtml", :content_type => "text/html"
end

def achievement
Expand Down
4 changes: 4 additions & 0 deletions app/mailers/guild_mailer.rb
Expand Up @@ -36,6 +36,10 @@ def weekly_summary( guild, email = nil, force = false )

@guild = guild
@items = @guild.guild_achievements.where( [ 'created_at >= ?', Date.today - 1.week ] ).includes(:character)
@people.each{|person,items|
# replace items in place
items[0..items.length] = items.sort_by{|i| [ (i.first ? 0 : 1), i.achievement_id * -1 ] }
}
@people = @items.group_by{|i| i.character }.sort_by{|character, items| [ character.achpoints * -1, character.rank ] }
@level_85 = @guild.characters.count(:conditions => [ "level >= 85" ] )
@total = @guild.characters.count
Expand Down

0 comments on commit 486d683

Please sign in to comment.