Changeset - fa90d7534537
[Not reviewed]
0 2 0
Lance Edgar (lance) - 7 years ago 2017-08-07 15:56:15
lance@edbob.org
Tweak how some batches are populated

to optimize for continuum versioning
2 files changed with 8 insertions and 11 deletions:
0 comments (0 inline, 0 general)
rattail/batch/pricing.py
Show inline comments
 
@@ -45,17 +45,15 @@ class PricingBatchHandler(BatchHandler):
 
        """
 
        assert batch.products
 
        session = orm.object_session(batch)
 

	
 
        def append(item, i):
 
            row = model.PricingBatchRow()
 
            with session.no_autoflush:
 
                row.product = item
 
                row.upc = row.product.upc
 
                batch.add_row(row)
 
            self.refresh_row(row)
 
            row.product = item
 
            row.upc = row.product.upc
 
            self.add_row(batch, row)
 

	
 
        assert self.progress_loop(append, batch.products, progress,
 
                                  message="Adding initial rows to batch")
 

	
 
    def refresh_row(self, row):
 
        """
rattail/batch/vendorcatalog.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2017 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
@@ -77,20 +77,19 @@ class VendorCatalogHandler(BatchHandler):
 
        parser.session = session
 
        parser.vendor = batch.vendor
 
        batch.effective = parser.parse_effective_date(path)
 
        self.setup_populate(batch, progress=progress)
 

	
 
        def append(row, i):
 
            batch.add_row(row)
 
            self.refresh_row(row)
 
            if i % 250 == 0:
 
            self.add_row(batch, row)
 
            if i % 5000 == 0:
 
                session.flush()
 

	
 
        data = list(parser.parse_rows(path, progress=progress))
 
        assert self.progress_loop(append, data, progress,
 
                                  message="Adding initial rows to batch")
 
        self.progress_loop(append, data, progress,
 
                           message="Adding initial rows to batch")
 

	
 
    def identify_product(self, row):
 
        product = None
 
        if row.upc:
 
            product = self.products['upc'].get(row.upc)
 
        if not product and row.vendor_code:
0 comments (0 inline, 0 general)