| Line 163... |
Line 163... |
| 163 |
ds_item.bestDealValue = item.bestDealValue
|
163 |
ds_item.bestDealValue = item.bestDealValue
|
| 164 |
ds_item.bestSellingRank = item.bestSellingRank
|
164 |
ds_item.bestSellingRank = item.bestSellingRank
|
| 165 |
|
165 |
|
| 166 |
ds_item.defaultForEntity = item.defaultForEntity
|
166 |
ds_item.defaultForEntity = item.defaultForEntity
|
| 167 |
ds_item.risky = item.risky
|
167 |
ds_item.risky = item.risky
|
| - |
|
168 |
ds_item.similarityIndex = item.similarityIndex
|
| 168 |
ds_item.updatedOn = datetime.datetime.now()
|
169 |
ds_item.updatedOn = datetime.datetime.now()
|
| 169 |
|
170 |
|
| 170 |
session.commit();
|
171 |
session.commit();
|
| 171 |
return ds_item.id
|
172 |
return ds_item.id
|
| 172 |
|
173 |
|
| Line 249... |
Line 250... |
| 249 |
ds_item.bestDealText = item.bestDealText
|
250 |
ds_item.bestDealText = item.bestDealText
|
| 250 |
if item.bestSellingRank:
|
251 |
if item.bestSellingRank:
|
| 251 |
ds_item.bestSellingRank = item.bestSellingRank
|
252 |
ds_item.bestSellingRank = item.bestSellingRank
|
| 252 |
ds_item.defaultForEntity = item.defaultForEntity
|
253 |
ds_item.defaultForEntity = item.defaultForEntity
|
| 253 |
ds_item.risky = item.risky
|
254 |
ds_item.risky = item.risky
|
| - |
|
255 |
if item.similarityIndex:
|
| - |
|
256 |
ds_item.similarityIndex = item.similarityIndex
|
| 254 |
|
257 |
|
| 255 |
# Check if a similar item already exists in our database
|
258 |
# Check if a similar item already exists in our database
|
| 256 |
similar_item = Item.query.filter_by(product_group=item.productGroup, brand = item.brand, model_number=item.modelNumber, hotspotCategory=item.hotspotCategory).first()
|
259 |
similar_item = Item.query.filter_by(product_group=item.productGroup, brand = item.brand, model_number=item.modelNumber, hotspotCategory=item.hotspotCategory).first()
|
| 257 |
print "[SIMILAR ITEM FOUND:] FOR {0} {1} {2} {3} {4}".format(item.productGroup, item.brand, item.modelNumber, item.hotspotCategory, item.color)
|
260 |
print "[SIMILAR ITEM FOUND:] FOR {0} {1} {2} {3} {4}".format(item.productGroup, item.brand, item.modelNumber, item.hotspotCategory, item.color)
|
| 258 |
|
261 |
|
| Line 893... |
Line 896... |
| 893 |
|
896 |
|
| 894 |
def get_risky_items():
|
897 |
def get_risky_items():
|
| 895 |
items = Item.query.filter_by(risky=True).all()
|
898 |
items = Item.query.filter_by(risky=True).all()
|
| 896 |
return items
|
899 |
return items
|
| 897 |
|
900 |
|
| - |
|
901 |
def get_similar_items_catalog_ids(start_index, stop_index, itemId):
|
| - |
|
902 |
similarity_index = Item.get_by(id = itemId).similarityIndex
|
| - |
|
903 |
if similarity_index is None:
|
| - |
|
904 |
return []
|
| - |
|
905 |
query = Item.query.filter_by(status=status.ACTIVE).filter_by(similarityIndex=similarity_index).filter(Item.id!=itemId).filter(Item.similarityIndex != None).group_by(Item.catalog_item_id)
|
| - |
|
906 |
similar_items = query.all()[start_index:stop_index]
|
| - |
|
907 |
return [item.catalog_item_id for item in similar_items]
|
| - |
|
908 |
|
| 898 |
def close_session():
|
909 |
def close_session():
|
| 899 |
if session.is_active:
|
910 |
if session.is_active:
|
| 900 |
print "session is active. closing it."
|
911 |
print "session is active. closing it."
|
| 901 |
session.close()
|
912 |
session.close()
|