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

Commit 485335e

Browse files
committed
refactor(cite-task): add some inline doc
1 parent e97cce1 commit 485335e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/groupher_server/cms/delegates/cite_tasks.ex

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
196196
|> Enum.uniq()
197197
end
198198

199+
# cite article in comment
199200
# 在评论中引用文章
200201
defp shape_cited_content(
201202
%Comment{} = comment,
@@ -208,13 +209,15 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
208209
comment_id: comment.id,
209210
block_linker: [block_id],
210211
user_id: comment.author_id,
212+
# extra fields for next-step usage
211213
# used for updating citing_count, avoid load again
212214
cited_content: cited_article,
213215
# for later insert all
214216
citing_time: comment.updated_at |> DateTime.truncate(:second)
215217
}
216218
end
217219

220+
# cite comment in comment
218221
# 评论中引用评论
219222
defp shape_cited_content(
220223
%Comment{} = comment,
@@ -227,13 +230,15 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
227230
comment_id: comment.id,
228231
block_linker: [block_id],
229232
user_id: comment.author_id,
233+
# extra fields for next-step usage
230234
# used for updating citing_count, avoid load again
231235
cited_content: cited_comment,
232236
# for later insert all
233237
citing_time: comment.updated_at |> DateTime.truncate(:second)
234238
}
235239
end
236240

241+
# cite article in article
237242
# 文章之间相互引用
238243
defp shape_cited_content(article, %{type: :article, content: cited_article}, block_id) do
239244
{:ok, thread} = thread_of_article(article)
@@ -244,6 +249,7 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
244249
cited_by_type: cited_article.meta.thread,
245250
block_linker: [block_id],
246251
user_id: article.author.user.id,
252+
# extra fields for next-step usage
247253
# used for updating citing_count, avoid load again
248254
cited_content: cited_article,
249255
# for later insert all
@@ -252,7 +258,8 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
252258
|> Map.put(info.foreign_key, article.id)
253259
end
254260

255-
# 文章里引用评论
261+
# cite comment in article
262+
# 文章中引用评论
256263
defp shape_cited_content(article, %{type: :comment, content: cited_comment}, block_id) do
257264
{:ok, thread} = thread_of_article(article)
258265
{:ok, info} = match(thread)
@@ -262,6 +269,7 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
262269
cited_by_type: "COMMENT",
263270
block_linker: [block_id],
264271
user_id: article.author.user.id,
272+
# extra fields for next-step usage
265273
# used for updating citing_count, avoid load again
266274
cited_content: cited_comment,
267275
# for later insert all
@@ -307,12 +315,6 @@ defmodule GroupherServer.CMS.Delegate.CiteTasks do
307315
defp is_comment_link?(url) do
308316
with %{query: query} <- URI.parse(url) do
309317
not is_nil(query) and String.starts_with?(query, "comment_id=")
310-
# is_valid_query = not is_nil(query) and String.starts_with?(query, "comment_id=")
311-
# comment_id = URI.decode_query(query) |> Map.get("comment_id")
312-
# query_not_empty = comment_id
313-
314-
# URI.decode_query(query) |> String.starts_with?("comment_id=")
315-
# IO.inspect(query, label: "the query")
316318
end
317319
end
318320

0 commit comments

Comments
 (0)