diff --git a/lib/groupher_server/cms/delegates/community_sync.ex b/lib/groupher_server/cms/delegates/community_sync.ex index 409036425..9804fa4d5 100644 --- a/lib/groupher_server/cms/delegates/community_sync.ex +++ b/lib/groupher_server/cms/delegates/community_sync.ex @@ -4,12 +4,14 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do """ import Ecto.Query, warn: false import Helper.ErrorCode - import Helper.CommonTypes # import ShortMaps + alias GroupherServer.CMS + alias Helper.ORM + alias Helper.SpecType, as: T - alias GroupherServer.CMS.{ + alias CMS.{ Community, CommunityWiki, CommunityCheatsheet @@ -46,7 +48,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do @doc """ sync wiki """ - @spec sync_github_content(Community.t(), atom) :: {:ok, CommunityWiki.t()} + @spec sync_github_content(Community.t(), atom(), any()) :: {:ok, CommunityWiki.t()} def sync_github_content(%Community{id: id}, :wiki, attrs) do with {:ok, community} <- ORM.find(Community, id) do attrs = Map.merge(attrs, %{community_id: community.id}) @@ -58,7 +60,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do @doc """ sync cheatsheet """ - @spec sync_github_content(Community.t(), atom()) :: {:ok, CommunityCheatsheet.t()} + @spec sync_github_content(Community.t(), atom(), any()) :: {:ok, CommunityCheatsheet.t()} def sync_github_content(%Community{id: id}, :cheatsheet, attrs) do with {:ok, community} <- ORM.find(Community, id) do attrs = Map.merge(attrs, %{community_id: community.id}) @@ -70,8 +72,8 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do @doc """ add contributor to exsit wiki contributors list """ - @spec add_contributor(Community.t(), github_contributor()) :: - {:ok, CommunityWiki} | custom_error() + @spec add_contributor(Community.t(), T.github_contributor()) :: + {:ok, CommunityWiki} | T.gq_error() def add_contributor(%CommunityWiki{id: id}, contributor_attrs) do do_add_contributor(CommunityWiki, id, contributor_attrs) end @@ -79,8 +81,8 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do @doc """ add contributor to exsit cheatsheet contributors list """ - @spec add_contributor(Community.t(), github_contributor()) :: - {:ok, CommunityCheatsheet} | custom_error() + @spec add_contributor(Community.t(), T.github_contributor()) :: + {:ok, CommunityCheatsheet} | T.gq_error() def add_contributor(%CommunityCheatsheet{id: id}, contributor_attrs) do do_add_contributor(CommunityCheatsheet, id, contributor_attrs) end diff --git a/lib/helper/common_types.ex b/lib/helper/common_types.ex deleted file mode 100644 index 9b02fec23..000000000 --- a/lib/helper/common_types.ex +++ /dev/null @@ -1,17 +0,0 @@ -defmodule Helper.CommonTypes do - @moduledoc """ - common types for lint - """ - - @type github_contributor :: %{ - github_id: String.t(), - avatar: String.t(), - html_url: String.t(), - nickname: String.t(), - bio: nil | String.t(), - location: nil | String.t(), - company: nil | String.t() - } - - @type custom_error :: {:error, [message: String.t(), code: Number.t()]} -end diff --git a/lib/helper/spec_type.ex b/lib/helper/spec_type.ex index 0b4a043de..40dd76b42 100644 --- a/lib/helper/spec_type.ex +++ b/lib/helper/spec_type.ex @@ -14,4 +14,17 @@ defmodule Helper.SpecType do @type done :: {:ok, map} | {:error, map} @type id :: non_neg_integer() | String.t() + + @typedoc """ + general contribute type for wiki and cheatshet + """ + @type github_contributor2 :: %{ + github_id: String.t(), + avatar: String.t(), + html_url: String.t(), + nickname: String.t(), + bio: nil | String.t(), + location: nil | String.t(), + company: nil | String.t() + } end