Performance improvements for ordergroup.update_stats!

As I have learned today. Let mysql do the counting, calculation stuff.
In most of the cases, it will be much faster!
This commit is contained in:
benni 2012-12-16 13:48:15 +01:00
parent 8074fedefd
commit b86172bc62
2 changed files with 6 additions and 3 deletions

View file

@ -28,7 +28,7 @@ class Order < ActiveRecord::Base
# Finders
scope :open, where(state: 'open').order('ends DESC')
scope :finished, where("state = 'finished' OR state = 'closed'").order('ends DESC')
scope :finished, where("orders.state = 'finished' OR orders.state = 'closed'").order('ends DESC')
scope :finished_not_closed, where(state: 'finished').order('ends DESC')
scope :closed, where(state: 'closed').order('ends DESC')
scope :stockit, where(supplier_id: 0).order('ends DESC')