Fixed `?selling_price`
parent
00d4f136de
commit
02845efaf2
|
@ -80,8 +80,8 @@ def get_player_by_name(mc_username):
|
|||
|
||||
def get_player(discord_uuid=None, mc_uuid=None):
|
||||
try:
|
||||
discord_uuid = str(discord_uuid)
|
||||
mc_uuid = str(mc_uuid)
|
||||
discord_uuid = str(discord_uuid) if discord_uuid else None
|
||||
mc_uuid = str(mc_uuid) if mc_uuid else None
|
||||
|
||||
if discord_uuid is not None:
|
||||
player = Player.objects.get(discord_uuid__iexact=discord_uuid)
|
||||
|
@ -456,10 +456,9 @@ def get_selling(item_name, sort):
|
|||
if len(item_name) == 0:
|
||||
raise EmptryString
|
||||
|
||||
all_shop_ids = ItemListing.objects.annotate(normalized_price=F('price') / F('amount')) \
|
||||
.filter(item_name__icontains=item_name).order_by(sort).values('shop_id').all()
|
||||
all_shop_ids = ItemListing.objects.filter(item_name__icontains=item_name).annotate(normalized_price=F('price') / F('amount')).order_by(sort).values("shop_id").all()
|
||||
|
||||
if len(all_shop_ids) == 0:
|
||||
if all_shop_ids.count() == 0:
|
||||
raise ItemNotFound
|
||||
|
||||
# Removes duplicates
|
||||
|
@ -473,7 +472,7 @@ def get_selling(item_name, sort):
|
|||
shop = Shop.objects.get(pk=shop_id['shop_id']).json
|
||||
|
||||
item_query = ItemListing.objects.filter(
|
||||
item_name__icontains=item_name, shop_id=shop_id['shop_id']).order_by(sort)
|
||||
item_name__icontains=item_name, shop_id=shop_id['shop_id']).order_by("-date_restocked")
|
||||
|
||||
item_list = []
|
||||
for item in item_query:
|
||||
|
|
|
@ -124,6 +124,13 @@ class CommandsAPITestCase(TestCase):
|
|||
|
||||
self.assertEqual(len(items), 1)
|
||||
|
||||
def test_selling_price(self):
|
||||
self.populate()
|
||||
|
||||
items = selling_price(item_name="sED")
|
||||
|
||||
self.assertEqual(len(items), 1)
|
||||
|
||||
def test_info(self):
|
||||
self.populate()
|
||||
location = info(location_name="test")
|
||||
|
|
Loading…
Reference in New Issue