<commit_before>defmodule Glasnost.CommentResolver do
  alias Glasnost.Repo
  import Ecto.Query

  def all(%{blockchain: blockchain, author: author}, _info) do
    schema = case blockchain do
      "steem" -> Glasnost.Steem.Comment
      "golos" -> Glasnost.Golos.Comment
    end
    q = from c in schema, order_by: [desc: c.created]
    q = if author do
      from c in q, where: c.author == ^author
    else
      q
    end
    {:ok, Repo.all(q)}
  end

  def find(%{"blockchain" => blockchain, author: a, permlink: p}, _info) do
    schema = case blockchain do
      :steem -> Glasnost.Steem.Comment
      :golos -> Glasnost.Golos.Comment
    end
    {:ok, Repo.find(schema, author: a, permlink: p)}
  end
end<commit_msg>add tag to query<commit_after>defmodule Glasnost.CommentResolver do
  alias Glasnost.Repo
  import Ecto.Query

  def all(%{blockchain: blockchain, author: author}, _info) do
    schema = case blockchain do
      "steem" -> Glasnost.Steem.Comment
      "golos" -> Glasnost.Golos.Comment
    end
    q = from c in schema, order_by: [desc: c.created]
    q = if author do
      from c in q, where: c.author == ^author
    else
      q
    end
    q = if tag do
      from c in q, where: tag in c.tags
    else
      q
    end
    {:ok, Repo.all(q)}
  end

  def find(%{"blockchain" => blockchain, author: a, permlink: p}, _info) do
    schema = case blockchain do
      :steem -> Glasnost.Steem.Comment
      :golos -> Glasnost.Golos.Comment
    end
    {:ok, Repo.find(schema, author: a, permlink: p)}
  end
end
{'fraction_non_alphanumeric': 0.11357702349869452, 'fraction_numerical': 0.0, 'mean_word_length': 2.5734265734265733, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '1073721', 'n_tokens_mistral': 544, 'n_tokens_neox': 541, 'n_words': 165}