✨ User product purchases over time
This commit is contained in:
1 parent
f3a6e563bb
commit
7474885f14
7 files changed
+147
-6
No files matched your search
@@ -17,6 +17,18 @@ class TopMonth:
|
||||
sum: int
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class Point:
|
||||
x: str
|
||||
y: int
|
||||
|
||||
|
||||
@strawberry.type
|
||||
class ProductOrderStat:
|
||||
product_name: str
|
||||
data: list[Point]
|
||||
|
||||
|
||||
@strawberry_django.type(models.UserProfile)
|
||||
class UserProfile:
|
||||
id: auto
|
||||
@@ -29,6 +41,13 @@ class UserProfile:
|
||||
def top_months(self) -> list[TopMonth]:
|
||||
return [TopMonth(**month) for month in self.top_months()]
|
||||
|
||||
@strawberry.field()
|
||||
def product_order_stats(self) -> list[ProductOrderStat]:
|
||||
return [
|
||||
ProductOrderStat(product_name=stat["product_name"], data=[Point(**p) for p in stat["data"]])
|
||||
for stat in self.product_order_stats().as_series()
|
||||
]
|
||||
|
||||
|
||||
@strawberry_django.type(UserModel)
|
||||
class User:
|
||||
|
||||
Reference in new issue
Block a user