mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
28 lines
735 B
Ruby
28 lines
735 B
Ruby
class HomeController < BaseController
|
|
layout 'darkswarm'
|
|
|
|
before_filter :enable_embedded_shopfront
|
|
|
|
def index
|
|
if ContentConfig.home_show_stats
|
|
@num_distributors = cached_count('distributors', Enterprise.is_distributor.activated.visible)
|
|
@num_producers = cached_count('producers', Enterprise.is_primary_producer.activated.visible)
|
|
@num_orders = cached_count('orders', Spree::Order.complete)
|
|
@num_users = cached_count(
|
|
'users', Spree::Order.complete.select('DISTINCT spree_orders.user_id')
|
|
)
|
|
end
|
|
end
|
|
|
|
def sell; end
|
|
|
|
private
|
|
|
|
# Cache the value of the query count
|
|
def cached_count(statistic, query)
|
|
CacheService.home_stats(statistic) do
|
|
query.count
|
|
end
|
|
end
|
|
end
|