You've already forked Promocode-API
mirror of
https://github.com/devitq/Promocode-API.git
synced 2026-05-23 22:37:11 +00:00
feat: added promocode activation
also code reformatting and bug fixes
This commit is contained in:
@@ -70,7 +70,9 @@ class CreatePromocodeOut(Schema):
|
||||
|
||||
|
||||
class PromocodeListFilters(Schema):
|
||||
limit: int = Field(10, gt=0, description="Limit must be greater than 0")
|
||||
limit: int = Field(
|
||||
10, ge=0, description="Limit must be greater than or equal 0"
|
||||
)
|
||||
offset: int = Field(
|
||||
0, ge=0, description="Offset must be greater than or equal to 0"
|
||||
)
|
||||
|
||||
@@ -172,8 +172,8 @@ def list_promocode(
|
||||
promocodes = promocodes.order_by("-created_at")
|
||||
|
||||
promocodes = promocodes.prefetch_related("activations", "likes").annotate(
|
||||
used_count=Count("activations"),
|
||||
like_count=Count("likes"),
|
||||
used_count=Count("activations", distinct=True),
|
||||
like_count=Count("likes", distinct=True),
|
||||
)
|
||||
|
||||
promocodes = promocodes[filters.offset : filters.offset + filters.limit]
|
||||
@@ -213,8 +213,8 @@ def get_promocode(
|
||||
promocodes.select_related("target")
|
||||
.prefetch_related("activations", "likes")
|
||||
.annotate(
|
||||
used_count=Count("activations"),
|
||||
like_count=Count("likes"),
|
||||
used_count=Count("activations", distinct=True),
|
||||
like_count=Count("likes", distinct=True),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -255,8 +255,8 @@ def patch_promocode(
|
||||
promocodes.select_related("target")
|
||||
.prefetch_related("activations", "likes")
|
||||
.annotate(
|
||||
used_count=Count("activations"),
|
||||
like_count=Count("likes"),
|
||||
used_count=Count("activations", distinct=True),
|
||||
like_count=Count("likes", distinct=True),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user