diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 7b8c362..e118b94 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -349,19 +349,26 @@ class ConferencesController < ApplicationController end else @registration_count = @registrations.size - @bikes = @registrations.count { |r| r.bike == 'yes' } - @donation_count =0 + @completed_registrations = 0 + @bikes = 0#@registrations.count { |r| r.bike == 'yes' } + @donation_count = 0 @donations = 0 @food = { meat: 0, vegan: 0, vegetarian: 0, all: 0 } @registrations.each do | r | - if r.food.present? + if r.steps_completed.include? 'questions' + @completed_registrations += 1 + + @bikes += 1 if r.bike == 'yes' + + #if r.food.present? @food[r.food.to_sym] += 1 @food[:all] += 1 - end + #end - if r.registration_fees_paid.present? && r.registration_fees_paid > 0 - @donation_count += 1 - @donations += r.registration_fees_paid + if r.registration_fees_paid.present? && r.registration_fees_paid > 0 + @donation_count += 1 + @donations += r.registration_fees_paid + end end end end diff --git a/app/views/conferences/admin/_stats.html.haml b/app/views/conferences/admin/_stats.html.haml index 14e29c7..a1ed3f9 100644 --- a/app/views/conferences/admin/_stats.html.haml +++ b/app/views/conferences/admin/_stats.html.haml @@ -1,16 +1,18 @@ .details - = data_set(:h4, 'articles.admin.stats.headings.registrations') do - = (@registration_count || 0).to_s + = data_set(:h4, 'articles.admin.stats.headings.completed_registrations') do + = (@completed_registrations || 0).to_s + = data_set(:h4, 'articles.admin.stats.headings.incomplete_registrations') do + = ((@registration_count - @completed_registrations) || 0).to_s = data_set(:h4, 'articles.admin.stats.headings.bikes') do - = (@registration_count || 0) > 0 ? "#{@bikes} (#{(@bikes / @registration_count) * 100.0}%)" : "0" + = (@completed_registrations || 0) > 0 ? "#{@bikes} (#{(@bikes / @completed_registrations.to_f).round(4) * 100.0}%)" : "0" = data_set(:h4, 'articles.admin.stats.headings.food.meat') do - = (@food[:all] || 0) > 0 ? "#{@food[:meat]} (#{(@food[:meat] / @food[:all]) * 100.0}%)" : "0" + = (@food[:all] || 0) > 0 ? "#{@food[:meat]} (#{(@food[:meat] / @food[:all].to_f).round(4) * 100.0}%)" : "0" = data_set(:h4, 'articles.admin.stats.headings.food.vegetarian') do - = (@food[:all] || 0) > 0 ? "#{@food[:vegetarian]} (#{(@food[:vegetarian] / @food[:all]) * 100.0}%)" : "0" + = (@food[:all] || 0) > 0 ? "#{@food[:vegetarian]} (#{(@food[:vegetarian] / @food[:all].to_f).round(4) * 100.0}%)" : "0" = data_set(:h4, 'articles.admin.stats.headings.food.vegan') do - = (@food[:all] || 0) > 0 ? "#{@food[:vegan]} (#{(@food[:vegan] / @food[:all]) * 100.0}%)" : "0" + = (@food[:all] || 0) > 0 ? "#{@food[:vegan]} (#{(@food[:vegan] / @food[:all].to_f).round(4) * 100.0}%)" : "0" = data_set(:h4, 'articles.admin.stats.headings.donation_count') do - = (@registration_count || 0) > 0 ? "#{@donation_count} (#{(@donation_count / @registration_count) * 100.0}%)" : "0" + = (@completed_registrations || 0) > 0 ? "#{@donation_count} (#{(@donation_count / @completed_registrations.to_f).round(4) * 100.0}%)" : "0" = data_set(:h4, 'articles.admin.stats.headings.donation_total') do = "$#{@donations || 0.00}" .actions diff --git a/config/locales/en.yml b/config/locales/en.yml index 055dc2e..aee50ad 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -870,6 +870,8 @@ en: vegetarian: Vegetarians vegan: Vegans registrations: Number of registrations + completed_registrations: Number of registrations + incomplete_registrations: Incomplete registrations housing: headings: guests: Guests