| Line 134... |
Line 134... |
| 134 |
#stmt = session.query(PrivateDeals).filter_by(isActive=1).filter(now().between(PrivateDeals.startDate, PrivateDeals.endDate)).subquery()
|
134 |
#stmt = session.query(PrivateDeals).filter_by(isActive=1).filter(now().between(PrivateDeals.startDate, PrivateDeals.endDate)).subquery()
|
| 135 |
#query = session.query(Item, privateDealAlias.dealPrice).outerjoin((privateDealAlias, Item.id==privateDealAlias.item_id)).filter(Item.status != status.PHASED_OUT)
|
135 |
#query = session.query(Item, privateDealAlias.dealPrice).outerjoin((privateDealAlias, Item.id==privateDealAlias.item_id)).filter(Item.status != status.PHASED_OUT)
|
| 136 |
tuples = session.query(Tag_Listing, Item).join((Item, Item.id==Tag_Listing.item_id)).filter(or_(Item.status==status.ACTIVE, Item.status==status.PAUSED_BY_RISK, Item.status==status.PARTIALLY_ACTIVE))
|
136 |
tuples = session.query(Tag_Listing, Item).join((Item, Item.id==Tag_Listing.item_id)).filter(or_(Item.status==status.ACTIVE, Item.status==status.PAUSED_BY_RISK, Item.status==status.PARTIALLY_ACTIVE))
|
| 137 |
projection={'defaultImageUrl':1}
|
137 |
projection={'defaultImageUrl':1}
|
| 138 |
for tag, item in tuples:
|
138 |
for tag, item in tuples:
|
| 139 |
if item.brand == "Live Demo" or not tag.active:
|
139 |
if item.brand == "Live Demo":
|
| 140 |
continue
|
140 |
continue
|
| 141 |
if not catalogMap.has_key(item.catalog_item_id):
|
141 |
if not catalogMap.has_key(item.catalog_item_id):
|
| 142 |
catalogObj = {}
|
142 |
catalogObj = {}
|
| 143 |
catalogObj['feature'] = ""
|
143 |
catalogObj['feature'] = ""
|
| 144 |
catalogObj['title'] = " ".join(filter(None, [item.brand, item.model_name, item.model_number]))
|
144 |
catalogObj['title'] = " ".join(filter(None, [item.brand, item.model_name, item.model_number]))
|
| Line 153... |
Line 153... |
| 153 |
try:
|
153 |
try:
|
| 154 |
catalogObj['imageUrl'] = get_mongo_connection(options.mongoHost).CONTENT.siteContent.find_one(filterMap, projection)['defaultImageUrl']
|
154 |
catalogObj['imageUrl'] = get_mongo_connection(options.mongoHost).CONTENT.siteContent.find_one(filterMap, projection)['defaultImageUrl']
|
| 155 |
print catalogObj['imageUrl']
|
155 |
print catalogObj['imageUrl']
|
| 156 |
except:
|
156 |
except:
|
| 157 |
try:
|
157 |
try:
|
| 158 |
catalogObj['imageUrl'] = 'http://images.smartdukaan.com/uploads/campaigns/' + str(item.catalog_item_id )+ '.jpg'
|
158 |
catalogObj['imageUrl'] = 'https://images.smartdukaan.com/uploads/campaigns/' + str(item.catalog_item_id )+ '.jpg'
|
| 159 |
except:
|
159 |
except:
|
| 160 |
traceback.print_exc()
|
160 |
traceback.print_exc()
|
| 161 |
try:
|
161 |
try:
|
| 162 |
catalogObj['rank'] = rankingList.index(item.catalog_item_id)
|
162 |
catalogObj['rank'] = rankingList.index(item.catalog_item_id)
|
| 163 |
except:
|
163 |
except:
|
| Line 174... |
Line 174... |
| 174 |
|
174 |
|
| 175 |
catalogObj = catalogMap.get(item.catalog_item_id)
|
175 |
catalogObj = catalogMap.get(item.catalog_item_id)
|
| 176 |
|
176 |
|
| 177 |
if tag.hot_deals:
|
177 |
if tag.hot_deals:
|
| 178 |
catalogObj['hot_deals'] = "True"
|
178 |
catalogObj['hot_deals'] = "True"
|
| 179 |
if not catalogObj['items'].has_key(item.id):
|
179 |
if tag.active and not catalogObj['items'].has_key(item.id):
|
| 180 |
catalogObj['items'][item.id] = {'color': item.color.replace("f_", ""), 'tagPricing':[]}
|
180 |
catalogObj['items'][item.id] = {'color': item.color.replace("f_", ""), 'tagPricing':[]}
|
| 181 |
|
- |
|
| 182 |
itemMap = catalogObj['items'].get(item.id)
|
181 |
itemMap = catalogObj['items'].get(item.id)
|
| 183 |
itemMap['tagPricing'].append(tag)
|
182 |
itemMap['tagPricing'].append(tag)
|
| 184 |
|
183 |
|
| 185 |
|
184 |
|
| 186 |
catalogObjs = []
|
185 |
catalogObjs = []
|
| 187 |
for catalogId, catalogMap in catalogMap.iteritems():
|
186 |
for catalogId, catalogMap in catalogMap.iteritems():
|
| 188 |
itemsMap = catalogMap['items']
|
187 |
itemsMap = catalogMap['items']
|
| Line 193... |
Line 192... |
| 193 |
itemObj = {'id':('itemtag-%s-%s'%(itemId, tag.tag_id)), 'color_s':itemMap['color'], 'itemId_i': itemId, 'tagId_i':tag.tag_id,
|
192 |
itemObj = {'id':('itemtag-%s-%s'%(itemId, tag.tag_id)), 'color_s':itemMap['color'], 'itemId_i': itemId, 'tagId_i':tag.tag_id,
|
| 194 |
'mop_f': tag.mop, 'sellingPrice_f': tag.selling_price}
|
193 |
'mop_f': tag.mop, 'sellingPrice_f': tag.selling_price}
|
| 195 |
itemObjs.append(itemObj)
|
194 |
itemObjs.append(itemObj)
|
| 196 |
catalogObj = {'id':'catalog' + str(catalogId), 'rank_i':catalogMap['rank'], 'title_s': catalogMap['title'],'hot_deals_b':catalogMap['hot_deals'],
|
195 |
catalogObj = {'id':'catalog' + str(catalogId), 'rank_i':catalogMap['rank'], 'title_s': catalogMap['title'],'hot_deals_b':catalogMap['hot_deals'],
|
| 197 |
'_childDocuments_':itemObjs,
|
196 |
'_childDocuments_':itemObjs,
|
| - |
|
197 |
'catalogId_i':catalogId,
|
| 198 |
'catalogId_i':catalogId, 'imageUrl_s': catalogMap['imageUrl'].replace("saholic", "smartdukaan"), 'feature_s':catalogMap['feature'],
|
198 |
'imageUrl_s': catalogMap['imageUrl'].replace("saholic", "smartdukaan"),
|
| - |
|
199 |
'feature_s':catalogMap['feature'],
|
| 199 |
'brand_ss': catalogMap['brand'], 'create_s':catalogMap['create_timestamp'], 'categoryId_i':catalogMap['categoryId'], 'subCategoryId_i':catalogMap['subCategoryId']}
|
200 |
'brand_ss': catalogMap['brand'], 'create_s':catalogMap['create_timestamp'],
|
| - |
|
201 |
'categoryId_i':catalogMap['categoryId'],
|
| - |
|
202 |
'subCategoryId_i':catalogMap['subCategoryId']}
|
| 200 |
print catalogObj
|
203 |
print catalogObj
|
| 201 |
catalogObjs.append(catalogObj)
|
204 |
catalogObjs.append(catalogObj)
|
| 202 |
solr.delete(q='*:*')
|
205 |
solr.delete(q='*:*')
|
| 203 |
solr.add(catalogObjs)
|
206 |
solr.add(catalogObjs)
|
| 204 |
|
207 |
|