move homies under gang
This commit is contained in:
@@ -4,11 +4,13 @@ class Homie < ApplicationRecord
|
||||
|
||||
belongs_to :gang
|
||||
|
||||
def self.info(importance)
|
||||
def self.info(importance, gang)
|
||||
# TODO: This can be improved
|
||||
|
||||
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|
|
||||
Homie.where(['importance > ? and gang_id = ?', importance, gang]).map do |homie|
|
||||
cash_total = cash_totals.fetch(homie.id, 0)
|
||||
work_total = work_totals.fetch(homie.id, 0)
|
||||
{ homie: homie, amount: cash_total, work: work_total }
|
||||
|
||||
Reference in New Issue
Block a user