| Line 1... |
Line 1... |
| 1 |
from elasticsearch import Elasticsearch
|
1 |
from elasticsearch import Elasticsearch
|
| 2 |
from dtr.utils.utils import get_mongo_connection
|
2 |
from dtr.utils.utils import get_mongo_connection
|
| 3 |
import optparse
|
3 |
import optparse
|
| 4 |
from pymongo import DESCENDING
|
4 |
from pymongo import ASCENDING
|
| 5 |
|
5 |
|
| 6 |
parser = optparse.OptionParser()
|
6 |
parser = optparse.OptionParser()
|
| 7 |
parser.add_option("-m", "--m", dest="mongoHost",
|
7 |
parser.add_option("-m", "--m", dest="mongoHost",
|
| 8 |
default="localhost",
|
8 |
default="localhost",
|
| 9 |
type="string", help="The HOST where the mongo server is running",
|
9 |
type="string", help="The HOST where the mongo server is running",
|
| Line 39... |
Line 39... |
| 39 |
added = []
|
39 |
added = []
|
| 40 |
items = list(get_mongo_connection(host=options.mongoHost).Catalog.MasterData.find({'subCategoryId':{"$in":subCategoryList}}))
|
40 |
items = list(get_mongo_connection(host=options.mongoHost).Catalog.MasterData.find({'subCategoryId':{"$in":subCategoryList}}))
|
| 41 |
for item in items:
|
41 |
for item in items:
|
| 42 |
if item['skuBundleId'] in added:
|
42 |
if item['skuBundleId'] in added:
|
| 43 |
continue
|
43 |
continue
|
| 44 |
deal_obj = list(get_mongo_connection().Catalog.Deals.find({'skuBundleId':item['skuBundleId']}).sort([('totalPoints',DESCENDING)]))
|
44 |
deal_obj = list(get_mongo_connection().Catalog.Deals.find({'skuBundleId':item['skuBundleId'],'internalRank':{"$gt":0}}).sort([('internalRank',ASCENDING)]))
|
| 45 |
if len(deal_obj) == 0:
|
45 |
if len(deal_obj) == 0:
|
| 46 |
internalRank = 999999
|
46 |
internalRank = 999999
|
| 47 |
else:
|
47 |
else:
|
| 48 |
internalRank = deal_obj[0]['internalRank']
|
48 |
internalRank = deal_obj[0]['internalRank']
|
| 49 |
title = xstr(item['brand'])+" "+xstr(item['model_name'])
|
49 |
title = xstr(item['brand'])+" "+xstr(item['model_name'])
|