Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit d5ee7f0

Browse files
committed
chore(article-comments): wip
1 parent 95fab62 commit d5ee7f0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/groupher_server/cms/delegates/article_comment_action.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommentAction do
256256
end
257257
end
258258

259+
defp get_article(%ArticleComment{repo_id: repo_id} = comment) when not is_nil(job_id) do
260+
with {:ok, article} <- ORM.find(CMS.Repo, comment.repo_id, preload: [author: :user]) do
261+
{:job, article}
262+
end
263+
end
264+
259265
@spec get_full_comment(String.t()) :: {:ok, T.article_info()} | {:error, nil}
260266
defp get_full_comment(comment_id) do
261267
query = from(c in ArticleComment, where: c.id == ^comment_id, preload: :post, preload: :job)
@@ -273,6 +279,10 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommentAction do
273279
do_extract_article_info(:job, job)
274280
end
275281

282+
defp extract_article_info(%ArticleComment{repo: %CMS.Repo{} = repo}) when not is_nil(repo) do
283+
do_extract_article_info(:repo, repo)
284+
end
285+
276286
@spec do_extract_article_info(T.article_thread(), T.article_common()) :: {:ok, T.article_info()}
277287
defp do_extract_article_info(thread, article) do
278288
with {:ok, article_with_author} <- Repo.preload(article, author: :user) |> done(),

0 commit comments

Comments
 (0)