add top10 and bottom10 products in dashboard

This commit is contained in:
phyusin
2017-11-17 10:22:04 +06:30
parent e5831f92f9
commit f333aa9a66
4 changed files with 23 additions and 2 deletions

View File

@@ -68,6 +68,7 @@ class HomeController < ApplicationController
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
@top_products = Sale.top_products(today).sum('i.qty')
@bottom_products = Sale.bottom_products(today).sum('i.qty')
@hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
# .sum(:grand_total)