mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-01-02 01:47:04 -05:00
feat: Implement initial schema and add various API, service, and management command enhancements across the application.
This commit is contained in:
@@ -47,9 +47,7 @@ def park_list_with_stats(*, filters: dict[str, Any] | None = None) -> QuerySet[P
|
||||
queryset = queryset.filter(location__country=filters["country"])
|
||||
if "search" in filters:
|
||||
search_term = filters["search"]
|
||||
queryset = queryset.filter(
|
||||
Q(name__icontains=search_term) | Q(description__icontains=search_term)
|
||||
)
|
||||
queryset = queryset.filter(Q(name__icontains=search_term) | Q(description__icontains=search_term))
|
||||
|
||||
return queryset.order_by("name")
|
||||
|
||||
@@ -74,15 +72,11 @@ def park_detail_optimized(*, slug: str) -> Park:
|
||||
"areas",
|
||||
Prefetch(
|
||||
"rides",
|
||||
queryset=Ride.objects.select_related(
|
||||
"manufacturer", "designer", "ride_model"
|
||||
),
|
||||
queryset=Ride.objects.select_related("manufacturer", "designer", "ride_model"),
|
||||
),
|
||||
Prefetch(
|
||||
"reviews",
|
||||
queryset=ParkReview.objects.select_related("user").filter(
|
||||
is_published=True
|
||||
),
|
||||
queryset=ParkReview.objects.select_related("user").filter(is_published=True),
|
||||
),
|
||||
"photos",
|
||||
)
|
||||
@@ -90,9 +84,7 @@ def park_detail_optimized(*, slug: str) -> Park:
|
||||
)
|
||||
|
||||
|
||||
def parks_near_location(
|
||||
*, point: Point, distance_km: float = 50, limit: int = 10
|
||||
) -> QuerySet[Park]:
|
||||
def parks_near_location(*, point: Point, distance_km: float = 50, limit: int = 10) -> QuerySet[Park]:
|
||||
"""
|
||||
Get parks near a specific geographic location.
|
||||
|
||||
@@ -176,16 +168,10 @@ def parks_with_recent_reviews(*, days: int = 30) -> QuerySet[Park]:
|
||||
cutoff_date = timezone.now() - timedelta(days=days)
|
||||
|
||||
return (
|
||||
Park.objects.filter(
|
||||
reviews__created_at__gte=cutoff_date, reviews__is_published=True
|
||||
)
|
||||
Park.objects.filter(reviews__created_at__gte=cutoff_date, reviews__is_published=True)
|
||||
.select_related("operator")
|
||||
.prefetch_related("location")
|
||||
.annotate(
|
||||
recent_review_count=Count(
|
||||
"reviews", filter=Q(reviews__created_at__gte=cutoff_date)
|
||||
)
|
||||
)
|
||||
.annotate(recent_review_count=Count("reviews", filter=Q(reviews__created_at__gte=cutoff_date)))
|
||||
.order_by("-recent_review_count")
|
||||
.distinct()
|
||||
)
|
||||
@@ -204,9 +190,7 @@ def park_search_autocomplete(*, query: str, limit: int = 10) -> QuerySet[Park]:
|
||||
"""
|
||||
return (
|
||||
Park.objects.filter(
|
||||
Q(name__icontains=query)
|
||||
| Q(location__city__icontains=query)
|
||||
| Q(location__region__icontains=query)
|
||||
Q(name__icontains=query) | Q(location__city__icontains=query) | Q(location__region__icontains=query)
|
||||
)
|
||||
.select_related("operator")
|
||||
.prefetch_related("location")
|
||||
|
||||
Reference in New Issue
Block a user