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:
@@ -186,21 +186,13 @@ class StatsAPIView(APIView):
|
||||
total_rides = Ride.objects.count()
|
||||
|
||||
# Company counts by role
|
||||
total_manufacturers = RideCompany.objects.filter(
|
||||
roles__contains=["MANUFACTURER"]
|
||||
).count()
|
||||
total_manufacturers = RideCompany.objects.filter(roles__contains=["MANUFACTURER"]).count()
|
||||
|
||||
total_operators = ParkCompany.objects.filter(
|
||||
roles__contains=["OPERATOR"]
|
||||
).count()
|
||||
total_operators = ParkCompany.objects.filter(roles__contains=["OPERATOR"]).count()
|
||||
|
||||
total_designers = RideCompany.objects.filter(
|
||||
roles__contains=["DESIGNER"]
|
||||
).count()
|
||||
total_designers = RideCompany.objects.filter(roles__contains=["DESIGNER"]).count()
|
||||
|
||||
total_property_owners = ParkCompany.objects.filter(
|
||||
roles__contains=["PROPERTY_OWNER"]
|
||||
).count()
|
||||
total_property_owners = ParkCompany.objects.filter(roles__contains=["PROPERTY_OWNER"]).count()
|
||||
|
||||
# Photo counts (combined)
|
||||
total_park_photos = ParkPhoto.objects.count()
|
||||
@@ -211,11 +203,7 @@ class StatsAPIView(APIView):
|
||||
total_roller_coasters = RollerCoasterStats.objects.count()
|
||||
|
||||
# Ride category counts
|
||||
ride_categories = (
|
||||
Ride.objects.values("category")
|
||||
.annotate(count=Count("id"))
|
||||
.exclude(category="")
|
||||
)
|
||||
ride_categories = Ride.objects.values("category").annotate(count=Count("id")).exclude(category="")
|
||||
|
||||
category_stats = {}
|
||||
for category in ride_categories:
|
||||
@@ -232,9 +220,7 @@ class StatsAPIView(APIView):
|
||||
"OT": "other_rides",
|
||||
}
|
||||
|
||||
category_name = category_names.get(
|
||||
category_code, f"category_{category_code.lower()}"
|
||||
)
|
||||
category_name = category_names.get(category_code, f"category_{category_code.lower()}")
|
||||
category_stats[category_name] = category_count
|
||||
|
||||
# Park status counts
|
||||
@@ -281,9 +267,7 @@ class StatsAPIView(APIView):
|
||||
"RELOCATED": "relocated_rides",
|
||||
}
|
||||
|
||||
status_name = status_names.get(
|
||||
status_code, f"ride_status_{status_code.lower()}"
|
||||
)
|
||||
status_name = status_names.get(status_code, f"ride_status_{status_code.lower()}")
|
||||
ride_status_stats[status_name] = status_count
|
||||
|
||||
# Review counts
|
||||
@@ -365,7 +349,7 @@ class StatsRecalculateAPIView(APIView):
|
||||
# Return success response with the fresh stats
|
||||
return Response(
|
||||
{
|
||||
"message": "Platform statistics have been successfully recalculated",
|
||||
"detail": "Platform statistics have been successfully recalculated",
|
||||
"stats": fresh_stats,
|
||||
"recalculated_at": timezone.now().isoformat(),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user