fix(noita): all objectives display
This commit is contained in:
@@ -87,15 +87,25 @@ def get_results(request: HttpRequest):
|
||||
)
|
||||
|
||||
# Build response with all objectives and compute total score
|
||||
objectives_with_points = []
|
||||
total_score = 0
|
||||
with_points = {}
|
||||
for obj in ObjectivPoint.objects.all():
|
||||
with_points[obj.objectiv_id] = {
|
||||
"objectiv_id": obj.objectiv_id,
|
||||
"display_string": obj.display_string,
|
||||
"count": 0,
|
||||
"max_count": obj.max_count,
|
||||
"points_per_objectiv": obj.point,
|
||||
"total_points": 0,
|
||||
"first_seen_at": None,
|
||||
"seed": None,
|
||||
}
|
||||
|
||||
for obj in user_objectives.order_by("-total_points"):
|
||||
points = obj["total_points"] or 0
|
||||
objectives_with_points.append(
|
||||
with_points[obj["objectiv_id"]].update(
|
||||
{
|
||||
"objectiv_id": obj["objectiv_id"],
|
||||
"count": obj["count"],
|
||||
"points_per_objectiv": obj["points_per_objectiv"] or 0,
|
||||
"total_points": points,
|
||||
"first_seen_at": obj["first_seen_at"],
|
||||
"seed": obj["seed"],
|
||||
@@ -109,7 +119,7 @@ def get_results(request: HttpRequest):
|
||||
data = {
|
||||
"total_score": total_score,
|
||||
"deaths_count": deaths_count,
|
||||
"objectives": objectives_with_points,
|
||||
"objectives": list(with_points.values()),
|
||||
}
|
||||
|
||||
cache.set(f"api:noita:results:{request.user.id}", data, 300)
|
||||
|
||||
@@ -15,10 +15,13 @@ class NoitaSubmissionOut(Schema):
|
||||
|
||||
class ObjectivResultOut(Schema):
|
||||
objectiv_id: str
|
||||
first_seen_at: datetime
|
||||
seed: str
|
||||
display_string: str
|
||||
first_seen_at: datetime | None
|
||||
count: int
|
||||
max_count: int
|
||||
seed: str | None
|
||||
points_per_objectiv: int
|
||||
total_points: int
|
||||
total_points: int | None
|
||||
|
||||
|
||||
class ResultsOut(Schema):
|
||||
|
||||
Reference in New Issue
Block a user