Skip to content

Instantly share code, notes, and snippets.

@Electron-libre
Created August 4, 2011 13:14
Show Gist options
  • Save Electron-libre/1125122 to your computer and use it in GitHub Desktop.
Save Electron-libre/1125122 to your computer and use it in GitHub Desktop.
Script reversement v1
accounts = Account.where(:ss7 => true).map { |a| [a.customer, a.code] }
report = []
accounts.each do |account|
account_report = []
account_count = []
Journal.where('account' => account[1], 'date' => /2011-07/).each do |journal|
account_report << journal.billing_entries.sum(:duration)
account_count << journal.billing_entries.where(:duration.gt => 0.0).count
end
report << [account[0], account[1], account_report.compact.sum, account_count.sum]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment