<commit_before>defmodule Pan.PodcastFrontendController do
  use Pan.Web, :controller

  alias Pan.Podcast
  alias Pan.Episode


  def index(conn, _params) do
    podcasts = Repo.all(Podcast)
               |> Repo.preload(:categories)
    render(conn, "index.html", podcasts: podcasts)
  end


  def show(conn, %{"id" => id}) do
    podcast = Repo.get!(Podcast, id)
    podcast = Repo.preload(podcast, [:languages, :owner, :feeds])
    podcast = Repo.preload(podcast, episodes: from(episode in Episode, order_by: [desc: episode.publishing_date]))
    render(conn, "show.html", podcast: podcast)
  end

  def like(conn, %{"id" => id}) do
    if conn.assigns.current_user do
      podcast = Repo.get!(Podcast, id)
      |> Repo.preload([:languages, :owner, :feeds, :followers])
      |> Repo.preload(episodes: from(episode in Episode, order_by: [desc: episode.publishing_date]))
      podcast
      |> Ecto.Changeset.change
      |> Ecto.Changeset.put_assoc(:followers, [conn.assigns.current_user | podcast.followers])
      |> Repo.update!

      podcast = Repo.get!(Podcast, id)
      |> Repo.preload([:languages, :owner, :feeds, :followers])
      |> Repo.preload(episodes: from(episode in Episode, order_by: [desc: episode.publishing_date]))<commit_msg>Use piping in controller action<commit_after>defmodule Pan.PodcastFrontendController do
  use Pan.Web, :controller

  alias Pan.Podcast
  alias Pan.Episode


  def index(conn, _params) do
    podcasts = Repo.all(Podcast)
               |> Repo.preload(:categories)
    render(conn, "index.html", podcasts: podcasts)
  end


  def show(conn, %{"id" => id}) do
    podcast = Repo.get!(Podcast, id)
    |> Repo.preload([:languages, :owner, :feeds, :followers])
    |> Repo.preload(episodes: from(episode in Episode, order_by: [desc: episode.publishing_date]))
    render(conn, "show.html", podcast: podcast)
  end

  def like(conn, %{"id" => id}) do
    if conn.assigns.current_user do
      podcast = Repo.get!(Podcast, id)
      |> Repo.preload([:languages, :owner, :feeds, :followers])
      |> Repo.preload(episodes: from(episode in Episode, order_by: [desc: episode.publishing_date]))
      podcast
      |> Ecto.Changeset.change
      |> Ecto.Changeset.put_assoc(:followers, [conn.assigns.current_user | podcast.followers])
      |> Repo.update!

      podcast = Repo.get!(Podcast, id)
      |> Repo.preload([:languages, :owner, :feeds, :followers])
      |> Repo.preload(episodes: from(episode in Episode, order_by: [desc: episode.publishing_date]))
{'fraction_non_alphanumeric': 0.145933014354067, 'fraction_numerical': 0.0, 'mean_word_length': 3.7518939393939394, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5442977', 'n_tokens_mistral': 901, 'n_tokens_neox': 872, 'n_words': 182}