From a800c7fff7fcc377a338fe4ebcc9abd89e0d2e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gremaud?= Date: Fri, 15 May 2026 20:43:30 +0200 Subject: [PATCH] fix(noita): all objectives display --- polylan_submitter/noita/api.py | 20 ++++++-- polylan_submitter/noita/schemas.py | 9 ++-- polylan_submitter/src/Noita.vue | 52 ++++++++++++-------- polylan_submitter/src/OpusMagnum.vue | 4 +- polylan_submitter/src/components/Results.vue | 14 +++--- 5 files changed, 63 insertions(+), 36 deletions(-) diff --git a/polylan_submitter/noita/api.py b/polylan_submitter/noita/api.py index 70047ec..26b2943 100644 --- a/polylan_submitter/noita/api.py +++ b/polylan_submitter/noita/api.py @@ -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) diff --git a/polylan_submitter/noita/schemas.py b/polylan_submitter/noita/schemas.py index 747e8bd..898825f 100644 --- a/polylan_submitter/noita/schemas.py +++ b/polylan_submitter/noita/schemas.py @@ -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): diff --git a/polylan_submitter/src/Noita.vue b/polylan_submitter/src/Noita.vue index 438f1ef..b8419d9 100644 --- a/polylan_submitter/src/Noita.vue +++ b/polylan_submitter/src/Noita.vue @@ -14,8 +14,11 @@ import { interface Objective { objectiv_id: string; - first_seen_at: string; - seed: string; + display_string: string; + first_seen_at: string | null; + count: number; + max_count: number; + seed: string | null; points_per_objectiv: number; total_points: number; } @@ -40,23 +43,21 @@ const columnHelper = createColumnHelper(); const sorting = ref([]); const columnFilters = ref([]); -const formatDate = (dateString: string) => { +const formatDate = (dateString: string | null) => { + if (!dateString) { + return "" + } const date = dayjs(dateString); return date.format("MMM DD, YYYY HH:mm"); }; -const getDateTooltip = (dateString: string) => { - const date = dayjs(dateString); - return date.format("dddd, MMMM D, YYYY [at] h:mm A"); -}; - const columns = [ columnHelper.accessor("objectiv_id", { header: "Objective ID", cell: (info) => info.getValue(), }), columnHelper.accessor("total_points", { - header: "Total Points", + header: "Your points", cell: (info) => info.getValue() || 0, }), columnHelper.accessor("first_seen_at", { @@ -65,6 +66,12 @@ const columns = [ sortingFn: (rowA, rowB) => { const dateA = dayjs(rowA.original.first_seen_at); const dateB = dayjs(rowB.original.first_seen_at); + if (!rowA.original.first_seen_at) { + return rowB.original.first_seen_at ? 1 : 0 + } + if (!rowB.original.first_seen_at) { + return rowA.original.first_seen_at ? 0 : 1 + } return dateA.isBefore(dateB) ? -1 : dateA.isAfter(dateB) ? 1 : 0; }, }), @@ -104,9 +111,7 @@ const table = computed(() => const itemData = row.getValue(columnId); const searchValue = value.toLowerCase(); if (columnId === "first_seen_at") { - const dateStr = itemData as string; - const formatted = dayjs(dateStr).format("MMM DD, YYYY HH:mm"); - return formatted.toLowerCase().includes(searchValue); + return formatDate(itemData as string).includes(searchValue) } return String(itemData).toLowerCase().includes(searchValue); }, @@ -284,7 +289,7 @@ onMounted(() => {