big speedup in syncing via caching/reducing queries (#610)

This commit is contained in:
Tom Carchrae 2019-01-14 17:56:21 -08:00 committed by Patrick Gansterer
parent 31689dfb75
commit 7e88798778
3 changed files with 19 additions and 7 deletions

View file

@ -154,7 +154,7 @@ class Article < ActiveRecord::Base
# to get the correspondent shared article
def shared_article(supplier = self.supplier)
self.order_number.blank? and return nil
@shared_article ||= supplier.shared_supplier.shared_articles.find_by_number(self.order_number) rescue nil
@shared_article ||= supplier.shared_supplier.find_article_by_number(self.order_number) rescue nil
end
# convert units in foodcoop-size