send total work hrs for homie
This commit is contained in:
@@ -3,12 +3,14 @@ class Homie < ApplicationRecord
|
||||
has_many :work
|
||||
belongs_to :chip
|
||||
|
||||
def self.cash(importance)
|
||||
totals = Homie.all.joins(:money_moves).group(:id).order(:id).sum(:amount)
|
||||
def self.info(importance)
|
||||
cash_totals = Homie.all.joins(:money_moves).group(:id).order(:id).sum(:amount)
|
||||
work_totals = Homie.all.joins(:work).group(:id).order(:id).sum(:amount)
|
||||
|
||||
Homie.where(["importance > ?", importance]).map do |homie|
|
||||
total = totals.fetch(homie.id, 0)
|
||||
{ homie: homie, amount: total }
|
||||
cash_total = cash_totals.fetch(homie.id, 0)
|
||||
work_total = work_totals.fetch(homie.id, 0)
|
||||
{ homie: homie, amount: cash_total, work: work_total }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user