Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit3b43815

Browse files
committed
chore: merge branch 'improve-spec' into dev
2 parents8ff259d +6f0ee76 commit3b43815

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

‎lib/groupher_server/cms/delegates/article_curd.ex‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
130130
end
131131
end
132132

133+
@specensure_author_exists(User.t())::{:ok,User.t()}
133134
defensure_author_exists(%User{}=user)do
134135
# unique_constraint: avoid race conditions, make sure user_id unique
135136
# foreign_key_constraint: check foreign key: user_id exsit or not

‎lib/groupher_server/cms/delegates/community_sync.ex‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
66
importHelper.ErrorCode
77
# import ShortMaps
88

9+
aliasGroupherServer.CMS
10+
911
aliasHelper.ORM
12+
aliasHelper.SpecType,as:T
1013

11-
aliasGroupherServer.CMS.{
14+
aliasCMS.{
1215
Community,
1316
CommunityWiki,
1417
CommunityCheatsheet
@@ -17,6 +20,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
1720
@doc"""
1821
get wiki
1922
"""
23+
@specget_wiki(Community.t())::{:ok,CommunityWiki.t()}
2024
defget_wiki(%Community{raw:raw})do
2125
with{:ok,community}<-ORM.find_by(Community,raw:raw),
2226
{:ok,wiki}<-ORM.find_by(CommunityWiki,community_id:community.id)do
@@ -30,6 +34,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
3034
@doc"""
3135
get cheatsheet
3236
"""
37+
@specget_cheatsheet(Community.t())::{:ok,CommunityCheatsheet.t()}
3338
defget_cheatsheet(%Community{raw:raw})do
3439
with{:ok,community}<-ORM.find_by(Community,raw:raw),
3540
{:ok,wiki}<-ORM.find_by(CommunityCheatsheet,community_id:community.id)do
@@ -43,6 +48,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
4348
@doc"""
4449
sync wiki
4550
"""
51+
@specsync_github_content(Community.t(),atom(),any())::{:ok,CommunityWiki.t()}
4652
defsync_github_content(%Community{id:id},:wiki,attrs)do
4753
with{:ok,community}<-ORM.find(Community,id)do
4854
attrs=Map.merge(attrs,%{community_id:community.id})
@@ -54,6 +60,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
5460
@doc"""
5561
sync cheatsheet
5662
"""
63+
@specsync_github_content(Community.t(),atom(),any())::{:ok,CommunityCheatsheet.t()}
5764
defsync_github_content(%Community{id:id},:cheatsheet,attrs)do
5865
with{:ok,community}<-ORM.find(Community,id)do
5966
attrs=Map.merge(attrs,%{community_id:community.id})
@@ -65,10 +72,17 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
6572
@doc"""
6673
add contributor to exsit wiki contributors list
6774
"""
75+
@specadd_contributor(Community.t(),T.github_contributor())::
76+
{:ok,CommunityWiki}|T.gq_error()
6877
defadd_contributor(%CommunityWiki{id:id},contributor_attrs)do
6978
do_add_contributor(CommunityWiki,id,contributor_attrs)
7079
end
7180

81+
@doc"""
82+
add contributor to exsit cheatsheet contributors list
83+
"""
84+
@specadd_contributor(Community.t(),T.github_contributor())::
85+
{:ok,CommunityCheatsheet}|T.gq_error()
7286
defadd_contributor(%CommunityCheatsheet{id:id},contributor_attrs)do
7387
do_add_contributor(CommunityCheatsheet,id,contributor_attrs)
7488
end

‎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
@typedone::{:ok,map}|{:error,map}
1515

1616
@typeid::non_neg_integer()|String.t()
17+
18+
@typedoc"""
19+
general contribute type for wiki and cheatshet
20+
"""
21+
@typegithub_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)

[8]ページ先頭

©2009-2025 Movatter.jp