<commit_before>defmodule Serverboards.Issues do
  alias Serverboards.Issues.Model

  def start_link(options \\ []) do
    import Supervisor.Spec
    children = [
      worker(Serverboards.Issues.EventSourcing, [[name: Serverboards.Issues.EventSourcing]]),
      worker(Serverboards.Issues.RPC, [[name: Serverboards.Issues.RPC]])
    ]

    Supervisor.start_link(children, [strategy: :one_for_one] ++ options)
  end

  def decorate_issues_list(i) do
    %{
      id: i.id,
      title: i.title,
      creator: Serverboards.Issues.Issue.decorate_user(i.creator),
      status: i.status,
      date: Ecto.DateTime.to_iso8601(Ecto.DateTime.cast! i.inserted_at),
      labels: Enum.map(i.labels, &Serverboards.Issues.Issue.decorate_label/1 )
    }
  end

  def list() do
    import Ecto.Query

    Serverboards.Repo.all(from i in Model.Issue, order_by: [desc: i.id], preload: [:creator, :labels])
     |> Enum.map(&decorate_issues_list/1)
  end
  def list(%{alias: alias_}) do
    import Ecto.Query

    Serverboards.Repo.all(
      from i in Model.Issue,
        join: a in Model.Alias, on: i.id == a.issue_id,
        where: a.alias == ^alias_,
        order_by: [desc: i.id],
        preload: [:creator, :labels]
        )
     |> Enum.map(&decorate_issues_list/1)
  end

end<commit_msg>Allow filter issues with empty filter<commit_after>defmodule Serverboards.Issues do
  alias Serverboards.Issues.Model

  def start_link(options \\ []) do
    import Supervisor.Spec
    children = [
      worker(Serverboards.Issues.EventSourcing, [[name: Serverboards.Issues.EventSourcing]]),
      worker(Serverboards.Issues.RPC, [[name: Serverboards.Issues.RPC]])
    ]

    Supervisor.start_link(children, [strategy: :one_for_one] ++ options)
  end

  def decorate_issues_list(i) do
    %{
      id: i.id,
      title: i.title,
      creator: Serverboards.Issues.Issue.decorate_user(i.creator),
      status: i.status,
      date: Ecto.DateTime.to_iso8601(Ecto.DateTime.cast! i.inserted_at),
      labels: Enum.map(i.labels, &Serverboards.Issues.Issue.decorate_label/1 )
    }
  end

  def list() do
    import Ecto.Query

    Serverboards.Repo.all(from i in Model.Issue, order_by: [desc: i.id], preload: [:creator, :labels])
     |> Enum.map(&decorate_issues_list/1)
  end
  def list(%{alias: alias_}) do
    import Ecto.Query

    Serverboards.Repo.all(
      from i in Model.Issue,
        join: a in Model.Alias, on: i.id == a.issue_id,
        where: a.alias == ^alias_,
        order_by: [desc: i.id],
        preload: [:creator, :labels]
        )
     |> Enum.map(&decorate_issues_list/1)
  end
  def list(%{}) do
    list()
  end

end
{'fraction_non_alphanumeric': 0.1311787072243346, 'fraction_numerical': 0.00532319391634981, 'mean_word_length': 2.9924127465857357, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3630656', 'n_tokens_mistral': 958, 'n_tokens_neox': 933, 'n_words': 183}