<commit_before>defmodule JumubaseWeb.Internal.StageController do
  use JumubaseWeb, :controller
  alias Jumubase.Foundation
  alias Jumubase.Foundation.Contest

  plug :add_home_breadcrumb
  plug :add_breadcrumb, name: gettext("Contests"), path_fun: &Routes.internal_contest_path/2, action: :index

  # Check nested contest permissions and pass to all actions
  def action(conn, _), do: contest_user_check_action(conn, __MODULE__)

  def index(conn, _params, contest) do
    %{host: %{stages: stages}} = Foundation.load_stages(contest)

    conn
    |> assign(:contest, contest)
    |> assign(:stages, stages)
    |> add_breadcrumbs(contest)<commit_msg>Sort stages by name before displaying them to user<commit_after>defmodule JumubaseWeb.Internal.StageController do
  use JumubaseWeb, :controller
  alias Jumubase.Foundation
  alias Jumubase.Foundation.Contest

  plug :add_home_breadcrumb
  plug :add_breadcrumb, name: gettext("Contests"), path_fun: &Routes.internal_contest_path/2, action: :index

  # Check nested contest permissions and pass to all actions
  def action(conn, _), do: contest_user_check_action(conn, __MODULE__)

  def index(conn, _params, contest) do
    %{host: %{stages: stages}} = Foundation.load_stages(contest)
    stages = stages |> Enum.sort_by(&(&1.name))

    conn
    |> assign(:contest, contest)
    |> assign(:stages, stages)
    |> add_breadcrumbs(contest)
{'fraction_non_alphanumeric': 0.10424155283968368, 'fraction_numerical': 0.002156721782890007, 'mean_word_length': 5.214285714285714, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '370728', 'n_tokens_mistral': 464, 'n_tokens_neox': 448, 'n_words': 108}