From 6c62b38cb56ad1a353865abca38c3bc14c1870b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Thu, 28 Nov 2024 21:21:41 +0100 Subject: [PATCH] Make @latest_scores order determinist This fix a broken test and ensure the view rendering is also deterministic. --- .../lib/transport_web/controllers/dataset_controller.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/transport/lib/transport_web/controllers/dataset_controller.ex b/apps/transport/lib/transport_web/controllers/dataset_controller.ex index b0f6dc00b5..bd82e1d6ee 100644 --- a/apps/transport/lib/transport_web/controllers/dataset_controller.ex +++ b/apps/transport/lib/transport_web/controllers/dataset_controller.ex @@ -129,7 +129,8 @@ defmodule TransportWeb.DatasetController do data |> Enum.reject(fn %DB.DatasetScore{score: score} -> is_nil(score) end) |> Enum.group_by(fn %DB.DatasetScore{topic: topic} -> topic end) - |> Map.new(fn {topic, scores} -> {topic, scores |> List.last() |> DB.DatasetScore.score_for_humans()} end) + |> Enum.map(fn {topic, scores} -> {topic, scores |> List.last() |> DB.DatasetScore.score_for_humans()} end) + |> Enum.sort_by(fn {a, _b} -> a end) merge_assigns(conn, %{scores_chart: scores_chart, latest_scores: latest_scores}) end