From 4a8c2d586ee88aba682cf3c00a9182c5c70f3f2f Mon Sep 17 00:00:00 2001 From: Nick Barnwell Date: Wed, 17 Sep 2014 00:49:13 -0700 Subject: [PATCH] Add shitty host overview page --- app/controllers/admin_controller.rb | 5 +++++ app/views/admin/host_overview.html.haml | 16 ++++++++++++++++ app/views/admin/overview.html.haml | 2 +- config/routes.rb | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 app/views/admin/host_overview.html.haml diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 23db5d75..4257be7b 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -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 diff --git a/app/views/admin/host_overview.html.haml b/app/views/admin/host_overview.html.haml new file mode 100644 index 00000000..1b458098 --- /dev/null +++ b/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, &:+) diff --git a/app/views/admin/overview.html.haml b/app/views/admin/overview.html.haml index 018d3b59..2dcf0dc8 100644 --- a/app/views/admin/overview.html.haml +++ b/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 diff --git a/config/routes.rb b/config/routes.rb index d93a3b36..ef283b19 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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'