| 94 |
ashish |
1 |
'''
|
|
|
2 |
Created on 23-Mar-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
|
|
6 |
from elixir import *
|
|
|
7 |
from shop2020.model.v1.catalog.impl import DataService
|
| 122 |
ashish |
8 |
from shop2020.model.v1.catalog.impl.DataService import Item, \
|
| 103 |
ashish |
9 |
Warehouse, ItemInventoryHistory, CurrentInventorySnapshot, ItemInfo,\
|
| 501 |
rajveer |
10 |
ItemChangeLog, Price, LatestArrivals, BestDeals, BestSellers
|
| 122 |
ashish |
11 |
from shop2020.thriftpy.model.v1.catalog.ttypes import \
|
|
|
12 |
InventoryServiceException, status
|
| 94 |
ashish |
13 |
from shop2020.thriftpy.model.v1.catalog.ttypes import Item as TItem
|
| 122 |
ashish |
14 |
|
| 94 |
ashish |
15 |
from shop2020.thriftpy.model.v1.catalog.ttypes import Warehouse as TWarehouse
|
|
|
16 |
import datetime
|
| 122 |
ashish |
17 |
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
|
| 501 |
rajveer |
18 |
from sqlalchemy import desc, asc
|
| 94 |
ashish |
19 |
|
|
|
20 |
|
|
|
21 |
def initialize():
|
|
|
22 |
DataService.initialize()
|
|
|
23 |
|
|
|
24 |
|
| 103 |
ashish |
25 |
def get_all_items(is_active):
|
|
|
26 |
if is_active:
|
| 122 |
ashish |
27 |
return Item.query.filter_by(status= status.ACTIVE).all()
|
| 103 |
ashish |
28 |
else:
|
|
|
29 |
return Item.query.all()
|
|
|
30 |
|
|
|
31 |
def get_all_items_by_status(status):
|
|
|
32 |
if not status:
|
|
|
33 |
#return all items
|
|
|
34 |
return get_all_items(False)
|
|
|
35 |
else:
|
| 122 |
ashish |
36 |
return Item.query.filter_by(status=status).all()
|
| 103 |
ashish |
37 |
|
| 94 |
ashish |
38 |
def get_Item(item_id):
|
|
|
39 |
return Item.get_by(id=item_id)
|
|
|
40 |
|
| 379 |
ashish |
41 |
def get_item_by_catalog_id(catalog_id):
|
| 447 |
rajveer |
42 |
query = Item.query.filter_by(catalog_item_id=catalog_id)
|
| 437 |
rajveer |
43 |
try:
|
|
|
44 |
return query.one()
|
|
|
45 |
except:
|
|
|
46 |
raise InventoryServiceException(109, "Item not found")
|
|
|
47 |
|
| 483 |
rajveer |
48 |
def get_item_by_vendor_id(vendor_id):
|
|
|
49 |
query = Item.query.filter_by(vendor_item_id=vendor_id)
|
| 494 |
rajveer |
50 |
#query = Item.query.filter_by(vendor_item_id='6417182037054')
|
| 483 |
rajveer |
51 |
try:
|
|
|
52 |
return query.one()
|
|
|
53 |
except:
|
|
|
54 |
raise InventoryServiceException(109, "Item not found")
|
|
|
55 |
|
| 94 |
ashish |
56 |
def get_Warehouse(warehouse_id):
|
|
|
57 |
return Warehouse.get_by(id=warehouse_id)
|
|
|
58 |
|
| 122 |
ashish |
59 |
def get_all_warehouses_by_status(status):
|
|
|
60 |
if not status:
|
|
|
61 |
return Warehouse.query.all()
|
|
|
62 |
else:
|
|
|
63 |
return Warehouse.query.filter_by(status=status)
|
|
|
64 |
|
| 94 |
ashish |
65 |
def get_all_warehouses_for_item(item_id):
|
|
|
66 |
item = get_Item(item_id)
|
|
|
67 |
if not item:
|
| 122 |
ashish |
68 |
raise InventoryServiceException(108, "Some unforeseen error while obtaining item")
|
|
|
69 |
return item.get_all_warehouses
|
| 94 |
ashish |
70 |
|
| 122 |
ashish |
71 |
def get_all_items_for_warehouse(warehouse_id):
|
|
|
72 |
warehouse = get_Warehouse(warehouse_id)
|
|
|
73 |
if not warehouse:
|
|
|
74 |
raise InventoryServiceException(108, "bad warehouse")
|
|
|
75 |
return warehouse.all_items
|
|
|
76 |
|
| 94 |
ashish |
77 |
def add_warehouse(warehouse):
|
| 103 |
ashish |
78 |
if not warehouse:
|
| 122 |
ashish |
79 |
raise InventoryServiceException(108, "Bad warehouse")
|
| 103 |
ashish |
80 |
if get_Warehouse(warehouse.id):
|
|
|
81 |
#warehouse is already present.
|
| 122 |
ashish |
82 |
raise InventoryServiceException(101, "Warehouse already present")
|
| 103 |
ashish |
83 |
|
| 94 |
ashish |
84 |
ds_warehouse = Warehouse()
|
|
|
85 |
ds_warehouse.id = warehouse.id
|
|
|
86 |
ds_warehouse.location = warehouse.location
|
| 122 |
ashish |
87 |
ds_warehouse.status = status.ACTIVE
|
| 103 |
ashish |
88 |
ds_warehouse.addedOn = datetime.datetime.now()
|
| 483 |
rajveer |
89 |
ds_warehouse.lastCheckedOn = datetime.datetime.now()
|
|
|
90 |
ds_warehouse.tinNumber = warehouse.tinNumber
|
|
|
91 |
ds_warehouse.pincode = warehouse.pincode
|
|
|
92 |
if warehouse.vendorString:
|
|
|
93 |
ds_warehouse.vendorString = warehouse.vendorString
|
| 94 |
ashish |
94 |
session.commit()
|
| 103 |
ashish |
95 |
return ds_warehouse.id
|
| 94 |
ashish |
96 |
|
| 122 |
ashish |
97 |
def update_item(item):
|
|
|
98 |
if not item:
|
|
|
99 |
raise InventoryServiceException(108, "Bad item in request")
|
|
|
100 |
|
|
|
101 |
if not item.id:
|
|
|
102 |
raise InventoryServiceException(101, "non existent item")
|
|
|
103 |
|
|
|
104 |
ds_item = get_Item(item.id)
|
|
|
105 |
|
|
|
106 |
if not ds_item:
|
|
|
107 |
raise InventoryServiceException(101, "Item already exists")
|
|
|
108 |
|
| 511 |
rajveer |
109 |
if item.manufacturerName:
|
|
|
110 |
ds_item.manufacturer_name = item.manufacturerName
|
|
|
111 |
if item.modelName:
|
|
|
112 |
ds_item.model_name = item.modelName
|
|
|
113 |
if item.modelNumber:
|
|
|
114 |
ds_item.model_number = item.modelNumber
|
| 483 |
rajveer |
115 |
if item.category:
|
|
|
116 |
ds_item.category = item.category
|
|
|
117 |
if item.comments:
|
|
|
118 |
ds_item.comments = item.comments
|
| 511 |
rajveer |
119 |
|
| 122 |
ashish |
120 |
if item.catalogItemId:
|
|
|
121 |
ds_item.catalog_item_id = item.catalogItemId
|
|
|
122 |
if item.vendorItemId:
|
|
|
123 |
ds_item.vendor_item_id = item.vendorItemId
|
|
|
124 |
else:
|
|
|
125 |
raise InventoryServiceException(101, "vendor item id cannot be missing")
|
| 483 |
rajveer |
126 |
|
|
|
127 |
if item.mrp:
|
|
|
128 |
ds_item.mrp = item.mrp
|
|
|
129 |
if item.mop:
|
|
|
130 |
ds_item.mop = item.mop
|
|
|
131 |
if item.sellingPrice:
|
|
|
132 |
ds_item.sellingPrice = item.sellingPrice
|
| 122 |
ashish |
133 |
if item.weight:
|
|
|
134 |
ds_item.weight = item.weight
|
| 511 |
rajveer |
135 |
if item.itemStatus:
|
|
|
136 |
ds_item.status = item.itemStatus
|
| 122 |
ashish |
137 |
|
| 511 |
rajveer |
138 |
if item.startDate:
|
|
|
139 |
ds_item.startDate = item.startDate
|
|
|
140 |
if item.retireDate:
|
|
|
141 |
ds_item.retireDate = item.retireDate
|
|
|
142 |
|
| 122 |
ashish |
143 |
if item.featureId:
|
|
|
144 |
ds_item.feature_id = item.featureId
|
|
|
145 |
if item.featureDescription:
|
|
|
146 |
ds_item.feature_description = item.featureDescription
|
|
|
147 |
|
|
|
148 |
session.commit();
|
|
|
149 |
return ds_item.id
|
| 94 |
ashish |
150 |
|
| 103 |
ashish |
151 |
def add_item(item):
|
|
|
152 |
if not item:
|
| 122 |
ashish |
153 |
raise InventoryServiceException(108, "Bad item in request")
|
| 103 |
ashish |
154 |
if get_Item(item.id):
|
| 122 |
ashish |
155 |
raise InventoryServiceException(101, "Item already exists")
|
| 483 |
rajveer |
156 |
|
| 103 |
ashish |
157 |
ds_item = Item()
|
| 122 |
ashish |
158 |
if item.id:
|
|
|
159 |
ds_item.id = item.id
|
| 515 |
rajveer |
160 |
if item.manufacturerName:
|
|
|
161 |
ds_item.manufacturer_name = item.manufacturerName
|
|
|
162 |
if item.modelName:
|
|
|
163 |
ds_item.model_name = item.modelName
|
|
|
164 |
if item.modelNumber:
|
|
|
165 |
ds_item.model_number = item.modelNumber
|
| 483 |
rajveer |
166 |
if item.category:
|
|
|
167 |
ds_item.category = item.category
|
|
|
168 |
if item.comments:
|
|
|
169 |
ds_item.comments = item.comments
|
|
|
170 |
|
| 122 |
ashish |
171 |
if item.catalogItemId:
|
|
|
172 |
ds_item.catalog_item_id = item.catalogItemId
|
|
|
173 |
if item.vendorItemId:
|
|
|
174 |
ds_item.vendor_item_id = item.vendorItemId
|
|
|
175 |
else:
|
|
|
176 |
raise InventoryServiceException(101, "vendor item id cannot be missing")
|
|
|
177 |
if item.itemStatus:
|
|
|
178 |
ds_item.status = item.itemStatus
|
|
|
179 |
else: #this is for update calls
|
|
|
180 |
ds_item.status = status.IN_PROCESS
|
| 103 |
ashish |
181 |
ds_item.addedOn = datetime.datetime.now()
|
| 483 |
rajveer |
182 |
if item.mrp:
|
|
|
183 |
ds_item.mrp = item.mrp
|
|
|
184 |
if item.mop:
|
|
|
185 |
ds_item.mop = item.mop
|
|
|
186 |
if item.sellingPrice:
|
|
|
187 |
ds_item.sellingPrice = item.sellingPrice
|
| 122 |
ashish |
188 |
if item.weight:
|
|
|
189 |
ds_item.weight = item.weight
|
|
|
190 |
|
|
|
191 |
if item.featureId:
|
|
|
192 |
ds_item.feature_id = item.featureId
|
|
|
193 |
if item.featureDescription:
|
|
|
194 |
ds_item.feature_description = item.featureDescription
|
|
|
195 |
|
| 103 |
ashish |
196 |
if item.otherInfo:
|
|
|
197 |
for k,v in item.otherInfo.iteritems():
|
|
|
198 |
info = ItemInfo()
|
|
|
199 |
info.key = k
|
|
|
200 |
info.value = v
|
|
|
201 |
ds_item.iteminfo.append(info)
|
|
|
202 |
#check if categories present. If yes, add them to system
|
| 122 |
ashish |
203 |
|
| 103 |
ashish |
204 |
session.commit();
|
|
|
205 |
return ds_item.id
|
|
|
206 |
|
| 483 |
rajveer |
207 |
#this is no more used
|
| 122 |
ashish |
208 |
def update_price(item, ds_item):
|
|
|
209 |
log_entry("update_price", "updating price for item")
|
|
|
210 |
for k,v in item.price.iteritems():
|
|
|
211 |
price = Price()
|
|
|
212 |
price.warehouse_id = k
|
|
|
213 |
price.price = v
|
| 386 |
ashish |
214 |
price.item = ds_item
|
|
|
215 |
session.commit()
|
| 122 |
ashish |
216 |
|
| 483 |
rajveer |
217 |
#this is no more used
|
| 122 |
ashish |
218 |
def update_price_for_warehouse(item_id, warehouse_id, price):
|
|
|
219 |
log_entry("update_price", "updating price for item and warehouse")
|
|
|
220 |
price = Price.query.filter_by(warehouse_id=warehouse_id, item_id=item_id).one()
|
|
|
221 |
if not price:
|
|
|
222 |
price = Price()
|
|
|
223 |
item = get_Item(item_id)
|
|
|
224 |
price.warehouse_id = warehouse_id
|
|
|
225 |
price.item = item
|
|
|
226 |
price.price = price
|
|
|
227 |
session.commit()
|
| 94 |
ashish |
228 |
|
|
|
229 |
|
| 483 |
rajveer |
230 |
def update_inventory(warehouse_id, timestamp, availability):
|
|
|
231 |
warehouse = get_Warehouse(warehouse_id)
|
|
|
232 |
if not warehouse:
|
|
|
233 |
raise InventoryServiceException(107, "Warehouse? Where?")
|
|
|
234 |
|
|
|
235 |
time = datetime.datetime.now()
|
|
|
236 |
warehouse.lastCheckedOn = time
|
|
|
237 |
warehouse.vendorString = timestamp
|
|
|
238 |
|
|
|
239 |
for k,v in availability.iteritems():
|
|
|
240 |
vendor_id = k
|
|
|
241 |
quantity = v
|
|
|
242 |
try:
|
| 494 |
rajveer |
243 |
item = Item.query.filter_by(vendor_item_id=vendor_id).one()
|
|
|
244 |
except:
|
|
|
245 |
continue
|
|
|
246 |
try:
|
| 483 |
rajveer |
247 |
item_inventory_history = ItemInventoryHistory()
|
|
|
248 |
item_inventory_history.warehouse = warehouse
|
|
|
249 |
item_inventory_history.item = item
|
|
|
250 |
item_inventory_history.timestamp = time
|
|
|
251 |
item_inventory_history.availibility = quantity
|
|
|
252 |
|
|
|
253 |
current_inventory_snapshot = CurrentInventorySnapshot.get_by(item=item, warehouse=warehouse)
|
|
|
254 |
if not current_inventory_snapshot:
|
|
|
255 |
current_inventory_snapshot = CurrentInventorySnapshot()
|
|
|
256 |
current_inventory_snapshot.item = item
|
|
|
257 |
current_inventory_snapshot.warehouse = warehouse
|
|
|
258 |
current_inventory_snapshot.availibility = 0
|
|
|
259 |
# added the difference in the current inventory
|
|
|
260 |
current_inventory_snapshot.availibility = current_inventory_snapshot.availibility + quantity
|
|
|
261 |
except:
|
|
|
262 |
raise InventoryServiceException(108, "Some unforeseen error while updating inventory")
|
|
|
263 |
session.commit()
|
|
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
|
267 |
#this is no more used
|
|
|
268 |
def update_inventory_old(item_id, warehouse_id, quantity, timestamp):
|
| 94 |
ashish |
269 |
item = get_Item(item_id)
|
|
|
270 |
warehouse = get_Warehouse(warehouse_id)
|
| 122 |
ashish |
271 |
time = to_py_date(timestamp)
|
| 94 |
ashish |
272 |
|
|
|
273 |
if not item:
|
| 122 |
ashish |
274 |
raise InventoryServiceException(106, "Item not found, how did you get this?")
|
| 94 |
ashish |
275 |
if not warehouse:
|
| 122 |
ashish |
276 |
raise InventoryServiceException(107, "Warehouse? Where?")
|
| 94 |
ashish |
277 |
try:
|
|
|
278 |
item_inventory_history = ItemInventoryHistory()
|
|
|
279 |
item_inventory_history.warehouse = warehouse
|
|
|
280 |
item_inventory_history.item = item
|
|
|
281 |
item_inventory_history.timestamp = time
|
| 122 |
ashish |
282 |
item_inventory_history.availibility = quantity
|
| 94 |
ashish |
283 |
|
|
|
284 |
current_inventory_snapshot = CurrentInventorySnapshot.get_by(item=item, warehouse=warehouse)
|
| 122 |
ashish |
285 |
if not current_inventory_snapshot:
|
|
|
286 |
current_inventory_snapshot = CurrentInventorySnapshot()
|
|
|
287 |
current_inventory_snapshot.item = item
|
|
|
288 |
current_inventory_snapshot.warehouse = warehouse
|
|
|
289 |
|
| 94 |
ashish |
290 |
current_inventory_snapshot.availibility = quantity
|
|
|
291 |
current_inventory_snapshot.checkedOn = time
|
|
|
292 |
session.commit()
|
|
|
293 |
except:
|
| 122 |
ashish |
294 |
raise InventoryServiceException(108, "Some unforeseen error while updating inventory")
|
| 94 |
ashish |
295 |
|
|
|
296 |
def get_item_inventoy(item_id):
|
|
|
297 |
|
|
|
298 |
inventory = Item.get_by(id=item_id).currentInventory
|
|
|
299 |
if not inventory:
|
| 122 |
ashish |
300 |
raise InventoryServiceException(108, "Some unforeseen error while updating inventory")
|
| 94 |
ashish |
301 |
return inventory
|
|
|
302 |
|
| 383 |
ashish |
303 |
def get_item_inventory_by_catalog_id(item_id):
|
| 379 |
ashish |
304 |
inventory = Item.get_by(catalog_item_id=item_id).currentInventory
|
|
|
305 |
if not inventory:
|
|
|
306 |
raise InventoryServiceException(108, "Some unforeseen error while updating inventory")
|
|
|
307 |
return inventory
|
|
|
308 |
|
| 103 |
ashish |
309 |
|
|
|
310 |
def retire_warehouse(warehouse_id):
|
|
|
311 |
if not warehouse_id:
|
| 122 |
ashish |
312 |
raise InventoryServiceException(101, "Bad warehouse id")
|
| 103 |
ashish |
313 |
warehouse = get_Warehouse(warehouse_id)
|
|
|
314 |
if not warehouse:
|
| 122 |
ashish |
315 |
raise InventoryServiceException(108, "warehouse id not present")
|
|
|
316 |
warehouse.status = status.DELETED;
|
| 103 |
ashish |
317 |
session.commit()
|
|
|
318 |
|
|
|
319 |
def retire_item(item_id):
|
|
|
320 |
if not item_id:
|
| 122 |
ashish |
321 |
raise InventoryServiceException(101, "bad item id")
|
| 103 |
ashish |
322 |
item = get_Item(item_id)
|
|
|
323 |
if not item:
|
| 122 |
ashish |
324 |
raise InventoryServiceException(108, "item id not present")
|
|
|
325 |
item.status = status.PHASED_OUT
|
|
|
326 |
item.retireDate = datetime.datetime.now()
|
| 103 |
ashish |
327 |
session.commit()
|
| 122 |
ashish |
328 |
|
|
|
329 |
#need to implement threads based solution here
|
| 103 |
ashish |
330 |
def start_item_on(item_id, timestamp):
|
|
|
331 |
if not item_id:
|
| 122 |
ashish |
332 |
raise InventoryServiceException(101, "bad item id")
|
| 103 |
ashish |
333 |
item = get_Item(item_id)
|
|
|
334 |
if not item:
|
| 122 |
ashish |
335 |
raise InventoryServiceException(108, "item id not present")
|
| 103 |
ashish |
336 |
|
| 122 |
ashish |
337 |
item.status = status.ACTIVE
|
|
|
338 |
item.startDate = datetime.datetime.fromtimestamp(to_py_date(timestamp))
|
|
|
339 |
add_status_change_log(item, status.ACTIVE)
|
| 103 |
ashish |
340 |
session.commit()
|
|
|
341 |
|
| 122 |
ashish |
342 |
#need to implement threads here
|
| 103 |
ashish |
343 |
def retire_item_on(item_id, timestamp):
|
|
|
344 |
if not item_id:
|
| 122 |
ashish |
345 |
raise InventoryServiceException(101, "bad item id")
|
| 103 |
ashish |
346 |
item = get_Item(item_id)
|
|
|
347 |
if not item:
|
| 122 |
ashish |
348 |
raise InventoryServiceException(108, "item id not present")
|
| 103 |
ashish |
349 |
|
| 122 |
ashish |
350 |
item.status = status.PHASED_OUT
|
|
|
351 |
item.retireDate = datetime.datetime.fromtimestamp(to_py_date(timestamp))
|
|
|
352 |
add_status_change_log(item, status.PHASED_OUT)
|
| 103 |
ashish |
353 |
session.commit()
|
|
|
354 |
|
|
|
355 |
def add_status_change_log(item, new_status):
|
|
|
356 |
item_change_log = ItemChangeLog()
|
|
|
357 |
item_change_log.new_status = new_status
|
|
|
358 |
item_change_log.old_status = item.status
|
|
|
359 |
item_change_log.timestamp = datetime.datetime.now()
|
|
|
360 |
item_change_log.item = item
|
|
|
361 |
session.commit()
|
|
|
362 |
|
|
|
363 |
def change_item_status(item_id, new_status):
|
|
|
364 |
if not item_id:
|
| 122 |
ashish |
365 |
raise InventoryServiceException(101, "bad item id")
|
| 103 |
ashish |
366 |
item = get_Item(item_id)
|
|
|
367 |
if not item:
|
| 122 |
ashish |
368 |
raise InventoryServiceException(108, "item id not present")
|
| 103 |
ashish |
369 |
|
| 122 |
ashish |
370 |
item.status = new_status
|
|
|
371 |
add_status_change_log(item, new_status)
|
| 103 |
ashish |
372 |
session.commit()
|
|
|
373 |
|
|
|
374 |
def get_item_availability_for_warehouse(warehouse_id, item_id):
|
|
|
375 |
if not warehouse_id:
|
| 122 |
ashish |
376 |
raise InventoryServiceException(101, "bad warehouse_id")
|
| 103 |
ashish |
377 |
if not item_id:
|
| 122 |
ashish |
378 |
raise InventoryServiceException(101, "bad item_id")
|
| 103 |
ashish |
379 |
|
|
|
380 |
warehouse = get_Warehouse(warehouse_id)
|
|
|
381 |
if not warehouse:
|
| 122 |
ashish |
382 |
raise InventoryServiceException(108, "warehouse does not exist")
|
| 504 |
rajveer |
383 |
item = get_item_by_catalog_id(item_id)
|
|
|
384 |
|
| 103 |
ashish |
385 |
if not item:
|
| 122 |
ashish |
386 |
raise InventoryServiceException(108, "item does not exist")
|
|
|
387 |
|
| 494 |
rajveer |
388 |
query = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_id)
|
| 504 |
rajveer |
389 |
query = query.filter_by(item_id = item.id)
|
| 494 |
rajveer |
390 |
try:
|
|
|
391 |
current_inventory_snapshot = query.one()
|
|
|
392 |
return current_inventory_snapshot.availibility
|
|
|
393 |
except:
|
|
|
394 |
return 0
|
|
|
395 |
"""
|
|
|
396 |
current_inventory_snapshot = CurrentInventorySnapshot.query.filter(CurrentInventorySnapshot.warehouse_id == warehouse_id, CurrentInventorySnapshot.item_id == item_id).one()
|
| 103 |
ashish |
397 |
if not current_inventory_snapshot:
|
|
|
398 |
return 0
|
|
|
399 |
else:
|
|
|
400 |
return current_inventory_snapshot.availibility
|
| 494 |
rajveer |
401 |
"""
|
| 122 |
ashish |
402 |
def get_warehouses_for_item(item_id):
|
|
|
403 |
if not item_id:
|
|
|
404 |
raise InventoryServiceException(101, "bad item_id")
|
|
|
405 |
item = get_Item(item_id)
|
|
|
406 |
|
|
|
407 |
if not item:
|
|
|
408 |
raise InventoryServiceException(101, "bad item")
|
|
|
409 |
|
| 483 |
rajveer |
410 |
warehouses = item.currentInventory.warehouse
|
| 501 |
rajveer |
411 |
return warehouses
|
|
|
412 |
|
|
|
413 |
def get_best_sellers():
|
|
|
414 |
sellers = BestSellers.query.all()
|
|
|
415 |
|
|
|
416 |
t_sellers = []
|
|
|
417 |
for seller in sellers:
|
|
|
418 |
t_sellers.append(seller.item_id)
|
|
|
419 |
return t_sellers
|
|
|
420 |
|
|
|
421 |
def get_best_deals():
|
|
|
422 |
deals = BestDeals.query.all()
|
|
|
423 |
|
|
|
424 |
#query = BestDeals.query.all()
|
|
|
425 |
#deals = query.order_by(asc(BestDeals.priority)).all()
|
|
|
426 |
|
|
|
427 |
|
|
|
428 |
t_deals = []
|
|
|
429 |
for deal in deals:
|
|
|
430 |
t_deals.append(deal.item_id)
|
|
|
431 |
return t_deals
|
|
|
432 |
|
|
|
433 |
def get_latest_arrivals():
|
|
|
434 |
arrivals = LatestArrivals.query.all()
|
|
|
435 |
|
|
|
436 |
t_arrivals = []
|
|
|
437 |
for arrival in arrivals:
|
|
|
438 |
t_arrivals.append(arrival.item_id)
|
|
|
439 |
return t_arrivals
|