Thanks to visit codestin.com
Credit goes to github.com

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

Commit 6f0ee76

Browse files
committed
refactor: add more spec
1 parent 9e05206 commit 6f0ee76

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

lib/groupher_server/cms/delegates/community_sync.ex

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
44
"""
55
import Ecto.Query, warn: false
66
import Helper.ErrorCode
7-
import Helper.CommonTypes
87
# import ShortMaps
98

9+
alias GroupherServer.CMS
10+
1011
alias Helper.ORM
12+
alias Helper.SpecType, as: T
1113

12-
alias GroupherServer.CMS.{
14+
alias CMS.{
1315
Community,
1416
CommunityWiki,
1517
CommunityCheatsheet
@@ -46,7 +48,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
4648
@doc """
4749
sync wiki
4850
"""
49-
@spec sync_github_content(Community.t(), atom) :: {:ok, CommunityWiki.t()}
51+
@spec sync_github_content(Community.t(), atom(), any()) :: {:ok, CommunityWiki.t()}
5052
def sync_github_content(%Community{id: id}, :wiki, attrs) do
5153
with {:ok, community} <- ORM.find(Community, id) do
5254
attrs = Map.merge(attrs, %{community_id: community.id})
@@ -58,7 +60,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
5860
@doc """
5961
sync cheatsheet
6062
"""
61-
@spec sync_github_content(Community.t(), atom()) :: {:ok, CommunityCheatsheet.t()}
63+
@spec sync_github_content(Community.t(), atom(), any()) :: {:ok, CommunityCheatsheet.t()}
6264
def sync_github_content(%Community{id: id}, :cheatsheet, attrs) do
6365
with {:ok, community} <- ORM.find(Community, id) do
6466
attrs = Map.merge(attrs, %{community_id: community.id})
@@ -70,17 +72,17 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
7072
@doc """
7173
add contributor to exsit wiki contributors list
7274
"""
73-
@spec add_contributor(Community.t(), github_contributor()) ::
74-
{:ok, CommunityWiki} | custom_error()
75+
@spec add_contributor(Community.t(), T.github_contributor()) ::
76+
{:ok, CommunityWiki} | T.gq_error()
7577
def add_contributor(%CommunityWiki{id: id}, contributor_attrs) do
7678
do_add_contributor(CommunityWiki, id, contributor_attrs)
7779
end
7880

7981
@doc """
8082
add contributor to exsit cheatsheet contributors list
8183
"""
82-
@spec add_contributor(Community.t(), github_contributor()) ::
83-
{:ok, CommunityCheatsheet} | custom_error()
84+
@spec add_contributor(Community.t(), T.github_contributor()) ::
85+
{:ok, CommunityCheatsheet} | T.gq_error()
8486
def add_contributor(%CommunityCheatsheet{id: id}, contributor_attrs) do
8587
do_add_contributor(CommunityCheatsheet, id, contributor_attrs)
8688
end

lib/helper/common_types.ex

Lines changed: 0 additions & 17 deletions
This file was deleted.

lib/helper/spec_type.ex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,17 @@ defmodule Helper.SpecType do
1414
@type done :: {:ok, map} | {:error, map}
1515

1616
@type id :: non_neg_integer() | String.t()
17+
18+
@typedoc """
19+
general contribute type for wiki and cheatshet
20+
"""
21+
@type github_contributor2 :: %{
22+
github_id: String.t(),
23+
avatar: String.t(),
24+
html_url: String.t(),
25+
nickname: String.t(),
26+
bio: nil | String.t(),
27+
location: nil | String.t(),
28+
company: nil | String.t()
29+
}
1730
end

0 commit comments

Comments
 (0)