Skip to content

Commit

Permalink
Merge pull request #208 from TeaWithStrangers/admin-overview-improvem…
Browse files Browse the repository at this point in the history
…ents

Add shitty host overview page
  • Loading branch information
Nick Barnwell committed Sep 17, 2014
2 parents e700702 + 4a8c2d5 commit d263c2a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/controllers/admin_controller.rb
Expand Up @@ -5,6 +5,11 @@ def find
end

def overview
@tea_times = TeaTime.all.order('start_time DESC')
end

def host_overview
@hosts = User.hosts.includes(:tea_times)
end

def users
Expand Down
16 changes: 16 additions & 0 deletions app/views/admin/host_overview.html.haml
@@ -0,0 +1,16 @@
.container
%table
%tr
%th Host Name
%th # TTs
%th Last Tea
%th Next Tea
%th Total Attendees
- @hosts.each do |h|
%tr
%td= link_to h.name, host_city_path(h, h.home_city)
%th= h.tea_times.count
- t = h.tea_times.where('start_time <= ?', Time.now.utc).last || "No tea time"
%th= link_to(t, tea_time_path(t))
%th= link_to h.tea_times.where('start_time >= ?', Time.now.utc).first || "No teas scheduled"
%th= h.tea_times.map {|t| t.attendances.count}.inject(0, &:+)
2 changes: 1 addition & 1 deletion app/views/admin/overview.html.haml
@@ -1,5 +1,5 @@
.container
- TeaTime.all.order(:start_time).each do |tt|
- @tea_times.each do |tt|
.row
=render partial: 'shared/tea_time_row', locals: {tea_time: tt}
%table.attendees
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -52,6 +52,7 @@
post '/ghost' => 'admin#ghost'

get '/overview' => 'admin#overview'
get '/overview/hosts' => 'admin#host_overview'
get '/users' => 'admin#users'

get '/mail' => 'admin#write_mail'
Expand Down

0 comments on commit d263c2a

Please sign in to comment.