mirror of
https://github.com/marking-hack/backend.git
synced 2024-11-22 09:26:38 +03:00
bug fixes
This commit is contained in:
parent
2d28b3bc48
commit
26b6096009
|
@ -20,13 +20,18 @@ class ItemSerializer(serializers.ModelSerializer):
|
|||
amount = obj.sales.first().amount
|
||||
if amount == nan:
|
||||
return 0
|
||||
return float(amount)
|
||||
try:
|
||||
return int(amount)
|
||||
except ValueError:
|
||||
return 0
|
||||
|
||||
def get_volume(self, obj):
|
||||
print(obj.volume)
|
||||
if obj.volume == nan:
|
||||
return 0
|
||||
return obj.volume
|
||||
try:
|
||||
return int(obj.volume)
|
||||
except ValueError:
|
||||
return 0
|
||||
|
||||
class Meta:
|
||||
model = Item
|
||||
|
|
|
@ -17,7 +17,7 @@ from marking_hack.market.models import Store, Region, StoreItem, Item
|
|||
class ListStore(generics.ListAPIView):
|
||||
serializer_class = StoreSerializer
|
||||
pagination_class = BigResultsSetPagination
|
||||
queryset = Store.objects.order_by("-id_sp")
|
||||
queryset = Store.objects.filter(sales__isnull=False).order_by("-id_sp").distinct()
|
||||
|
||||
|
||||
class ListStoreItems(generics.ListAPIView):
|
||||
|
@ -74,5 +74,6 @@ class PredictItemsView(generics.GenericAPIView):
|
|||
else:
|
||||
print(qs)
|
||||
items.append({"id": x_item, "predicted_volume": 0})
|
||||
shop["items"] = items
|
||||
data["shops"] = shops
|
||||
return Response(data=data)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 4.1.7 on 2023-03-26 11:53
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("market", "0010_itemtransaction_sender_region_code"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name="storeitem",
|
||||
options={"ordering": ["date"]},
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="city",
|
||||
name="name",
|
||||
field=models.CharField(max_length=150),
|
||||
),
|
||||
]
|
|
@ -15,7 +15,7 @@ class City(models.Model):
|
|||
fias = models.UUIDField(
|
||||
default=uuid.uuid4, editable=False, unique=True, db_index=True
|
||||
)
|
||||
name = models.CharField(max_length=250)
|
||||
name = models.CharField(max_length=150)
|
||||
|
||||
|
||||
class Store(models.Model):
|
||||
|
@ -110,4 +110,4 @@ class StoreItem(models.Model):
|
|||
amount = models.IntegerField()
|
||||
|
||||
class Meta:
|
||||
ordering = ["-date"]
|
||||
ordering = ["date"]
|
||||
|
|
Loading…
Reference in New Issue
Block a user