mirror of
https://github.com/marking-hack/backend.git
synced 2025-02-16 17:20:34 +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
|
amount = obj.sales.first().amount
|
||||||
if amount == nan:
|
if amount == nan:
|
||||||
return 0
|
return 0
|
||||||
return float(amount)
|
try:
|
||||||
|
return int(amount)
|
||||||
|
except ValueError:
|
||||||
|
return 0
|
||||||
|
|
||||||
def get_volume(self, obj):
|
def get_volume(self, obj):
|
||||||
print(obj.volume)
|
|
||||||
if obj.volume == nan:
|
if obj.volume == nan:
|
||||||
return 0
|
return 0
|
||||||
return obj.volume
|
try:
|
||||||
|
return int(obj.volume)
|
||||||
|
except ValueError:
|
||||||
|
return 0
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Item
|
model = Item
|
||||||
|
|
|
@ -17,7 +17,7 @@ from marking_hack.market.models import Store, Region, StoreItem, Item
|
||||||
class ListStore(generics.ListAPIView):
|
class ListStore(generics.ListAPIView):
|
||||||
serializer_class = StoreSerializer
|
serializer_class = StoreSerializer
|
||||||
pagination_class = BigResultsSetPagination
|
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):
|
class ListStoreItems(generics.ListAPIView):
|
||||||
|
@ -74,5 +74,6 @@ class PredictItemsView(generics.GenericAPIView):
|
||||||
else:
|
else:
|
||||||
print(qs)
|
print(qs)
|
||||||
items.append({"id": x_item, "predicted_volume": 0})
|
items.append({"id": x_item, "predicted_volume": 0})
|
||||||
|
shop["items"] = items
|
||||||
data["shops"] = shops
|
data["shops"] = shops
|
||||||
return Response(data=data)
|
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(
|
fias = models.UUIDField(
|
||||||
default=uuid.uuid4, editable=False, unique=True, db_index=True
|
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):
|
class Store(models.Model):
|
||||||
|
@ -110,4 +110,4 @@ class StoreItem(models.Model):
|
||||||
amount = models.IntegerField()
|
amount = models.IntegerField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ["-date"]
|
ordering = ["date"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user