Subversion Repositories SmartDukaan

Rev

Rev 17772 | Rev 17778 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17772 Rev 17777
Line 1... Line 1...
1
from elixir import *
1
from elixir import *
2
from dtr.storage.MemCache import MemCache
2
from dtr.storage.MemCache import MemCache
3
from shop2020.model.v1.catalog.impl import DataService as CatalogDataService
3
from shop2020.model.v1.catalog.impl import DataService as CatalogDataService
4
from shop2020.model.v1.inventory.impl import DataService as InventoryDataService
4
from shop2020.model.v1.inventory.impl import DataService as InventoryDataService
5
from shop2020.model.v1.catalog.impl.DataService import Item
5
from shop2020.model.v1.catalog.impl.DataService import Item, PrivateDeals
6
from shop2020.model.v1.inventory.impl.DataService import ItemAvailabilityCache
6
from shop2020.model.v1.inventory.impl.DataService import ItemAvailabilityCache
7
from dtr.utils.utils import get_mongo_connection, SOURCE_MAP
7
from dtr.utils.utils import get_mongo_connection, SOURCE_MAP
8
import optparse
8
import optparse
9
import traceback
9
import traceback
-
 
10
from datetime import datetime 
10
 
11
 
11
parser = optparse.OptionParser()
12
parser = optparse.OptionParser()
12
parser.add_option("-H", "--host", dest="hostname",
13
parser.add_option("-H", "--host", dest="hostname",
13
                      default="localhost",
14
                      default="localhost",
14
                      type="string", help="The HOST where the DB server is running",
15
                      type="string", help="The HOST where the DB server is running",
Line 67... Line 68...
67
        if fetch > totalLength:
68
        if fetch > totalLength:
68
            fetch = totalLength
69
            fetch = totalLength
69
            toBreak = True
70
            toBreak = True
70
            
71
            
71
        item_list = bundleMap.keys()[start:fetch]
72
        item_list = bundleMap.keys()[start:fetch]
72
        items = session.query(Item).filter(Item.catalog_item_id.in_(item_list)).all()
73
        items = session.query(Item,PrivateDeals).outerjoin((PrivateDeals,Item.id==PrivateDeals.item_id)).filter(Item.catalog_item_id.in_(item_list)).all()
73
        print items
74
        print items
74
        for i in items:
75
        for i in items:
-
 
76
            d_item = i[0]
-
 
77
            d_privatedeal = i[1]
75
            tempList = bundleMap.get(i.catalog_item_id)
78
            tempList = bundleMap.get(d_item.catalog_item_id)
-
 
79
            sellingPrice = d_item.sellingPrice
-
 
80
            sellingPriceType = "Normal"
-
 
81
            if d_privatedeal is not None and d_privatedeal.isActive==1 and d_privatedeal.startDate > datetime.now() and d_privatedeal.endDate < datetime.now() and d_privatedeal.dealPrice >0:
-
 
82
                sellingPrice = d_privatedeal.dealPrice
-
 
83
                sellingPriceType = "Private deal price"
76
            tempList.append({'item_id':i.id,'color':i.color})
84
            tempList.append({'item_id':d_item.id,'color':d_item.color,'sellingPrice':sellingPrice})
77
        if toBreak:
85
        if toBreak:
78
            print "Breaking"
86
            print "Breaking"
79
            break
87
            break
80
        start = fetch
88
        start = fetch
81
        fetch = start + fetch
89
        fetch = start + fetch