From 1ffba674b331b2480f7ebedd3a6c1d1b507f9463 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 6 May 2015 11:31:32 +1000 Subject: [PATCH] Show real stats on home page --- app/controllers/home_controller.rb | 7 +++++-- app/views/home/_stats.html.haml | 30 ++++++++++++++---------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 76e179ed22..ff78019015 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,11 +1,14 @@ class HomeController < BaseController layout 'darkswarm' before_filter :load_active_distributors - + def index + @num_hubs = Enterprise.is_hub.count + @num_producers = Enterprise.is_primary_producer.count + @num_users = Spree::User.joins(:orders).count('DISTINCT spree_users.*') + @num_orders = Spree::Order.complete.count end def about_us end end - diff --git a/app/views/home/_stats.html.haml b/app/views/home/_stats.html.haml index 71d0ae4770..135a28dfa3 100644 --- a/app/views/home/_stats.html.haml +++ b/app/views/home/_stats.html.haml @@ -5,25 +5,23 @@ %p.text-big Thanks for making the Open Food Network possible. Our vision is a better food system, and we're proud of what we're achieving together. %br %br - // Todo: make these variables live from OFN data. - // Todo: investigate state / postcode / location stat. Easy / hard? - .stat1 - %h4 - %strong 4 - states represented - .stat1 - %h4 - %strong 126 + -# .stat1 + -# %h4 + -# %strong 44444 + -# states represented + .stat2 + %h4 + %strong= number_with_delimiter @num_hubs food shops .stat3 - %h4 - %strong 345 + %h4 + %strong= number_with_delimiter @num_producers food producers .stat4 - %h4 - %strong 2,201 + %h4 + %strong= number_with_delimiter @num_users happy food shoppers .stat5 - %h4 - %strong 3,902 - orders made \ No newline at end of file + %h4 + %strong= number_with_delimiter @num_orders + orders made