Subversion Repositories SmartDukaan

Rev

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

Rev 14179 Rev 14253
Line 11... Line 11...
11
con = None
11
con = None
12
dealsCatalogIds = []
12
dealsCatalogIds = []
13
itemCatalogMap = {}
13
itemCatalogMap = {}
14
 
14
 
15
parser = optparse.OptionParser()
15
parser = optparse.OptionParser()
16
parser.add_option("-H", "--host", dest="hostname",
16
parser.add_option("-h", "--host", dest="hostname",
17
                      default="localhost",
17
                      default="localhost",
18
                      type="string", help="The HOST where the DB server is running",
18
                      type="string", help="The HOST where the DB server is running",
19
                      metavar="HOST")
19
                      metavar="host")
-
 
20
parser.add_option("-m", "--m", dest="mongoHost",
-
 
21
                      default="localhost",
-
 
22
                      type="string", help="The HOST where the mongo server is running",
-
 
23
                      metavar="mongo_host")
20
 
24
 
21
(options, args) = parser.parse_args()
25
(options, args) = parser.parse_args()
22
DataService.initialize(db_hostname=options.hostname)
26
DataService.initialize(db_hostname=options.hostname)
23
 
27
 
24
def get_mongo_connection(host='localhost', port=27017):
28
def get_mongo_connection(host=options.mongoHost, port=27017):
25
    global con
29
    global con
26
    if con is None:
30
    if con is None:
27
        print "Establishing connection %s host and port %d" %(host,port)
31
        print "Establishing connection %s host and port %d" %(host,port)
28
        try:
32
        try:
29
            con = pymongo.MongoClient(host, port)
33
            con = pymongo.MongoClient(host, port)
Line 52... Line 56...
52
        saholicCatalogIds = list(get_mongo_connection().Catalog.MasterData.find({'skuBundleId':bestSeller['skuBundleId'],'source_id':4}))
56
        saholicCatalogIds = list(get_mongo_connection().Catalog.MasterData.find({'skuBundleId':bestSeller['skuBundleId'],'source_id':4}))
53
        for d in saholicCatalogIds:
57
        for d in saholicCatalogIds:
54
            if d['source_id']!=4:
58
            if d['source_id']!=4:
55
                continue
59
                continue
56
            dealsCatalogIds.append(long(d['identifier'].strip()))
60
            dealsCatalogIds.append(long(d['identifier'].strip()))
-
 
61
#    dealFlagged = list(get_mongo_connection().Catalog.Deals.find({'source_id':4,'showDeal':1,'totalPoints':{'$gt':0}}))
-
 
62
#    for deal in dealFlagged:
-
 
63
#        if not (deal['_id']) in dealsCatalogIds:
-
 
64
#            dealsCatalogIds.append(long(deal['identifier'].strip()))
57
    items = Item.query.filter(Item.catalog_item_id.in_(dealsCatalogIds)).all()
65
    items = Item.query.filter(Item.catalog_item_id.in_(dealsCatalogIds)).all()
58
    for item in items:
66
    for item in items:
59
        temp = []
67
        temp = []
60
        if not itemCatalogMap.has_key(item.catalog_item_id):
68
        if not itemCatalogMap.has_key(item.catalog_item_id):
61
            temp.append(item)
69
            temp.append(item)