Files
openfoodnetwork/app/controllers/home_controller.rb
Luis Ramos e52937c113 Use rubocop auto correct to add frozen string literal to all files
This is an unsafe auto corection, we will need to trust our build here
2021-06-17 23:07:26 +01:00

34 lines
848 B
Ruby

# frozen_string_literal: true
class HomeController < BaseController
layout 'darkswarm'
before_action :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
def unauthorized
render 'shared/unauthorized', status: :unauthorized
end
private
# Cache the value of the query count
def cached_count(statistic, query)
CacheService.home_stats(statistic) do
query.count
end
end
end