Skip to content

Commit

Permalink
Refactoring of one statistics function
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Altmann committed Mar 1, 2016
1 parent 628b921 commit 25609f5
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions app/models/statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,10 @@ def revenue_last_month
fair = 0
fee = 0

BusinessTransaction.where(
'sold_at > ?
AND sold_at < ?
AND business_transactions.state = ?',
1.month.ago.at_beginning_of_month,
1.month.ago.at_end_of_month,
'sold'
).select { |bt| bt.seller.is_a?(LegalEntity) }.each do |t|
BusinessTransaction
.where(sold_at: 1.month.ago.beginning_of_month..1.month.ago.end_of_month)
.select { |bt| bt.seller.is_a?(LegalEntity) }
.each do |t|
if t.article
unless t.refund
fair += t.quantity_bought * t.article.calculated_fair_cents
Expand Down

0 comments on commit 25609f5

Please sign in to comment.