| Line 124... |
Line 124... |
| 124 |
|
124 |
|
| 125 |
|
125 |
|
| 126 |
def populateTagItems():
|
126 |
def populateTagItems():
|
| 127 |
|
127 |
|
| 128 |
|
128 |
|
| 129 |
tagRankingList = session.query(Tag_Ranking.catalogItemId).order_by(desc(Tag_Ranking.rankPoints)).all()
|
129 |
tagRankingList = session.query(Tag_Ranking).order_by(desc(Tag_Ranking.rankPoints)).all()
|
| 130 |
tagRankingList = [catalogId for (catalogId,) in tagRankingList]
|
130 |
rankingList = []
|
| 131 |
|
131 |
featureMap = {}
|
| - |
|
132 |
for tagRanking in tagRankingList:
|
| - |
|
133 |
rankingList.append(tagRanking.catalogItemId)
|
| - |
|
134 |
featureMap[tagRanking.catalogItemId]=tagRanking.feature
|
| 132 |
catalogMap = {}
|
135 |
catalogMap = {}
|
| 133 |
#stmt = session.query(PrivateDeals).filter_by(isActive=1).filter(now().between(PrivateDeals.startDate, PrivateDeals.endDate)).subquery()
|
136 |
#stmt = session.query(PrivateDeals).filter_by(isActive=1).filter(now().between(PrivateDeals.startDate, PrivateDeals.endDate)).subquery()
|
| 134 |
#query = session.query(Item, privateDealAlias.dealPrice).outerjoin((privateDealAlias, Item.id==privateDealAlias.item_id)).filter(Item.status != status.PHASED_OUT)
|
137 |
#query = session.query(Item, privateDealAlias.dealPrice).outerjoin((privateDealAlias, Item.id==privateDealAlias.item_id)).filter(Item.status != status.PHASED_OUT)
|
| 135 |
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))
|
138 |
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 |
projection={'defaultImageUrl':1}
|
139 |
projection={'defaultImageUrl':1}
|
| Line 155... |
Line 158... |
| 155 |
try:
|
158 |
try:
|
| 156 |
catalogObj['imageUrl'] = 'http://api.profittill.com/uploads/campaigns/' + str(item.catalog_item_id )+ '.jpg'
|
159 |
catalogObj['imageUrl'] = 'http://api.profittill.com/uploads/campaigns/' + str(item.catalog_item_id )+ '.jpg'
|
| 157 |
except:
|
160 |
except:
|
| 158 |
traceback.print_exc()
|
161 |
traceback.print_exc()
|
| 159 |
try:
|
162 |
try:
|
| 160 |
catalogObj['rank'] = tagRankingList.index(item.catalog_item_id)
|
163 |
catalogObj['rank'] = rankingList.index(item.catalog_item_id)
|
| 161 |
except:
|
164 |
except:
|
| 162 |
#A very big number
|
165 |
#A very big number
|
| - |
|
166 |
traceback.print_exc()
|
| 163 |
catalogObj['rank'] = 50000000
|
167 |
catalogObj['rank'] = 50000000
|
| - |
|
168 |
try:
|
| - |
|
169 |
catalogObj['feature'] = featureMap.get(item.catalog_item_id)
|
| - |
|
170 |
except:
|
| - |
|
171 |
catalogObj['feature'] = None
|
| 164 |
traceback.print_exc()
|
172 |
traceback.print_exc()
|
| 165 |
#Mobile and tablets are showcased in same category
|
173 |
#Mobile and tablets are showcased in same category
|
| 166 |
catalogObj['categoryId'] = 3 if item.category in [10006, 10009] else 6
|
174 |
catalogObj['categoryId'] = 3 if item.category in [10006, 10009] else 6
|
| 167 |
catalogObj['create_timestamp'] = to_java_date(tag.create_timestamp)
|
175 |
catalogObj['create_timestamp'] = to_java_date(tag.create_timestamp)
|
| 168 |
catalogMap[item.catalog_item_id] = catalogObj
|
176 |
catalogMap[item.catalog_item_id] = catalogObj
|
| Line 189... |
Line 197... |
| 189 |
itemObj = {'id':('itemtag-%s-%s'%(itemId, tag.tag_id)), 'color_s':itemMap['color'], 'itemId_i': itemId, 'tagId_i':tag.tag_id,
|
197 |
itemObj = {'id':('itemtag-%s-%s'%(itemId, tag.tag_id)), 'color_s':itemMap['color'], 'itemId_i': itemId, 'tagId_i':tag.tag_id,
|
| 190 |
'mop_f': tag.mop, 'sellingPrice_f': tag.selling_price}
|
198 |
'mop_f': tag.mop, 'sellingPrice_f': tag.selling_price}
|
| 191 |
itemObjs.append(itemObj)
|
199 |
itemObjs.append(itemObj)
|
| 192 |
catalogObj = {'id':'catalog' + str(catalogId), 'rank_i':catalogMap['rank'], 'title_s': catalogMap['title'],'hot_deals_b':catalogMap['hot_deals'],
|
200 |
catalogObj = {'id':'catalog' + str(catalogId), 'rank_i':catalogMap['rank'], 'title_s': catalogMap['title'],'hot_deals_b':catalogMap['hot_deals'],
|
| 193 |
'_childDocuments_':itemObjs,
|
201 |
'_childDocuments_':itemObjs,
|
| 194 |
'catalogId_i':catalogId, 'imageUrl_s': catalogMap['imageUrl'],
|
202 |
'catalogId_i':catalogId, 'imageUrl_s': catalogMap['imageUrl'], 'feature_s':catalogMap['feature']
|
| 195 |
'brand_ss': catalogMap['brand'], 'create_s':catalogMap['create_timestamp'], 'categoryId_i':catalogMap['categoryId']}
|
203 |
'brand_ss': catalogMap['brand'], 'create_s':catalogMap['create_timestamp'], 'categoryId_i':catalogMap['categoryId']}
|
| 196 |
catalogObjs.append(catalogObj)
|
204 |
catalogObjs.append(catalogObj)
|
| 197 |
solr.delete(q='*:*')
|
205 |
solr.delete(q='*:*')
|
| 198 |
solr.add(catalogObjs)
|
206 |
solr.add(catalogObjs)
|
| 199 |
|
207 |
|