<commit_before>defmodule PanWeb.Live.Recommendation.Random do
  use Surface.LiveView, container: {:div, class: "m-4"}
  alias PanWeb.Surface.{PodcastButton, EpisodeButton, CategoryButton}
  alias PanWeb.{Podcast, Category}

  def mount(_params, _session, socket) do
    podcast = Podcast.random()
    category = List.first(podcast.categories).id |> Category.get_by_id()
    episode = Enum.random(podcast.episodes)

    {:ok,
     assign(socket,
       podcast: podcast,
       episode: episode,
       category: category,
       page_title: "Random Recommendation"
     )}
  end

  def render(assigns) do
    ~F"""
    <h1 class="text-3xl">A Random Recommendation</h1>
    <p class="mt-4 leading-9">
      Fortuna opted for the episode &nbsp; <EpisodeButton for={@episode} /> &nbsp;
      from the podcast  &nbsp; <PodcastButton for={@podcast} /> &nbsp;
      in the category  &nbsp;<CategoryButton for={@category} /> &nbsp;.
    </p>
    """
  end
end<commit_msg>show only one random recommendation<commit_after>defmodule PanWeb.Live.Recommendation.Random do
  use Surface.LiveView, container: {:div, class: "m-4"}
  alias PanWeb.Surface.{PodcastButton, EpisodeButton, CategoryButton}
  alias PanWeb.{Podcast, Category}

  def mount(_params, _session, socket) do
    if connected?(socket) do
      podcast = Podcast.random()
      category = List.first(podcast.categories).id |> Category.get_by_id()
      episode = Enum.random(podcast.episodes)

      {:ok,
       assign(socket,
         podcast: podcast,
         episode: episode,
         category: category,
         page_title: "Random Recommendation"
       )}
    else
      {:ok, assign(socket, page_title: "Random Recommendation")}
    end
  end

  def render(assigns) do
    if Map.has_key?(assigns, :podcast) do
      ~F"""
      <h1 class="text-3xl">A Random Recommendation</h1>
      <p class="mt-4 leading-9">
        Fortuna opted for the episode &nbsp; <EpisodeButton for={@episode} /> &nbsp;
        from the podcast  &nbsp; <PodcastButton for={@podcast} /> &nbsp;
        in the category  &nbsp;<CategoryButton for={@category} /> &nbsp;.
      </p>
      """
    else
      ~F"""
      <h1 class="text-3xl">A Random Recommendation</h1>
      <p class="mt-4 leading-9">
        loading ...
      </p>
      """
    end
  end
end
{'fraction_non_alphanumeric': 0.13315926892950392, 'fraction_numerical': 0.0073977371627502175, 'mean_word_length': 2.9366438356164384, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7137945', 'n_tokens_mistral': 762, 'n_tokens_neox': 741, 'n_words': 181}