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.

Commit2f69341

Browse files
authored
refactor(community): redesign (#364)
* refactor(community): rename table && clean up warnings* refactor(community): re-org macro helper file* refactor(community): wip* refactor(community): wip* refactor(community): more test* refactor(community): wip* refactor(community): wip* refactor(community): add views to community* refactor(community): move articles_count to outside field* refactor(test): skip old post comment test* chore: fmt* fix(article): add viewer_has states when read* refactor: sync subscribe count to community* refactor: move subscribe count & viewer_has logic* refactor(community): enhance read community & test* refactor(community): fmt* fix(community): meta nil edge-case* fix(community): editor count & tests* fix(community): remove editors subscribers in community fields* fix(community): remove editors subscribers in community fields* fix(community): error test* fix(community): error test* fix(community): error test
1 parent9a59768 commit2f69341

File tree

56 files changed

+1655
-634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1655
-634
lines changed

‎cover/excoveralls.json‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎lib/groupher_server/accounts/delegates/collect_folder.ex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule GroupherServer.Accounts.Delegate.CollectFolder do
33
user collect folder related
44
"""
55
importEcto.Query,warn:false
6-
importGroupherServer.CMS.Helper.Matcher2
6+
importGroupherServer.CMS.Helper.Matcher
77

88
aliasHelper.Types,as:T
99
aliasHelper.QueryBuilder

‎lib/groupher_server/accounts/delegates/publish.ex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule GroupherServer.Accounts.Delegate.Publish do
77
# import Helper.ErrorCode
88
importShortMaps
99

10-
importGroupherServer.CMS.Helper.Matcher
10+
importGroupherServer.CMS.Helper.MatcherOld
1111

1212
aliasHelper.{ORM,QueryBuilder}
1313
# alias GroupherServer.{Accounts, Repo}

‎lib/groupher_server/accounts/delegates/upvoted_articles.ex‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ defmodule GroupherServer.Accounts.Delegate.UpvotedArticles do
22
@moduledoc"""
33
get contents(posts, jobs ...) that user upvotes
44
"""
5-
# import GroupherServer.CMS.Helper.Matcher
65
importEcto.Query,warn:false
76
importHelper.Utils,only:[done:1]
87
importShortMaps

‎lib/groupher_server/cms/cms.ex‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ defmodule GroupherServer.CMS do
3131
# see https://github.com/elixir-lang/elixir/issues/5306
3232

3333
# Community CURD: editors, thread, tag
34+
defdelegateread_community(args),to:CommunityCURD
35+
defdelegateread_community(args,user),to:CommunityCURD
36+
defdelegatecreate_community(args),to:CommunityCURD
37+
defdelegateupdate_community(id,args),to:CommunityCURD
3438
# >> editor ..
3539
defdelegateupdate_editor(user,community,title),to:CommunityCURD
3640
# >> geo info ..
@@ -51,9 +55,6 @@ defmodule GroupherServer.CMS do
5155
defdelegateunset_article_tag(thread,article_id,tag_id),to:ArticleTag
5256
defdelegatepaged_article_tags(filter),to:ArticleTag
5357

54-
defdelegatecreate_tag(community,thread,attrs,user),to:CommunityCURD
55-
defdelegateupdate_tag(attrs),to:CommunityCURD
56-
5758
# >> wiki & cheatsheet (sync with github)
5859
defdelegateget_wiki(community),to:CommunitySync
5960
defdelegateget_cheatsheet(community),to:CommunitySync
@@ -113,9 +114,6 @@ defmodule GroupherServer.CMS do
113114
defdelegateundo_pin_article(thread,id,community_id),to:ArticleCommunity
114115
defdelegatelock_article_comment(article),to:ArticleCommunity
115116

116-
# >> tag: set / unset
117-
defdelegateset_tag(thread,tag,content_id),to:ArticleCommunity
118-
defdelegateunset_tag(thread,tag,content_id),to:ArticleCommunity
119117
# >> community: set / unset
120118
defdelegatemirror_article(thread,article_id,community_id),to:ArticleCommunity
121119
defdelegateunmirror_article(thread,article_id,community_id),to:ArticleCommunity

‎lib/groupher_server/cms/community.ex‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ defmodule GroupherServer.CMS.Community do
99
aliasGroupherServer.{Accounts,CMS}
1010

1111
aliasCMS.{
12+
Embeds,
1213
Category,
1314
CommunityThread,
1415
CommunitySubscriber,
@@ -35,13 +36,22 @@ defmodule GroupherServer.CMS.Community do
3536
field(:raw,:string)
3637
field(:index,:integer)
3738
field(:geo_info,:map)
39+
field(:views,:integer)
3840

41+
embeds_one(:meta,Embeds.CommunityMeta,on_replace::delete)
3942
belongs_to(:author,Accounts.User,foreign_key::user_id)
4043

4144
has_many(:threads,{"communities_threads",CommunityThread})
4245
has_many(:subscribers,{"communities_subscribers",CommunitySubscriber})
4346
has_many(:editors,{"communities_editors",CommunityEditor})
4447

48+
field(:articles_count,:integer,default:0)
49+
field(:editors_count,:integer,default:0)
50+
field(:subscribers_count,:integer,default:0)
51+
52+
field(:viewer_has_subscribed,:boolean,default:false,virtual:true)
53+
field(:viewer_is_editor,:boolean,default:false,virtual:true)
54+
4555
has_one(:wiki,CommunityWiki)
4656
has_one(:cheatsheet,CommunityCheatsheet)
4757

@@ -68,6 +78,7 @@ defmodule GroupherServer.CMS.Community do
6878
community
6979
|>cast(attrs,@optional_fields++@required_fields)
7080
|>validate_required(@required_fields)
81+
|>cast_embed(:meta,with:&Embeds.CommunityMeta.changeset/2)
7182
|>validate_length(:title,min:1,max:30)
7283
|>foreign_key_constraint(:user_id)
7384
|>unique_constraint(:title,name::communities_title_index)
@@ -82,6 +93,7 @@ defmodule GroupherServer.CMS.Community do
8293
# |> unique_constraint(:title, name: :communities_title_index)
8394
community
8495
|>cast(attrs,@optional_fields++@required_fields)
96+
|>cast_embed(:meta,with:&Embeds.CommunityMeta.changeset/2)
8597
|>validate_length(:title,min:1,max:30)
8698
|>foreign_key_constraint(:user_id)
8799
|>unique_constraint(:title,name::communities_title_index)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule GroupherServer.CMS.Delegate.AbuseReport do
55
importEcto.Query,warn:false
66
importHelper.Utils,only:[done:1,strip_struct:1,get_config:2]
77

8-
importGroupherServer.CMS.Helper.Matcher2
8+
importGroupherServer.CMS.Helper.Matcher
99
importShortMaps
1010

1111
aliasHelper.ORM

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCollect do
22
@moduledoc"""
33
reaction[upvote, collect, watch ...] on article [post, job...]
44
"""
5-
importGroupherServer.CMS.Helper.Matcher2
5+
importGroupherServer.CMS.Helper.Matcher
66
importEcto.Query,warn:false
77
importHelper.Utils,only:[done:1]
88

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
77
importHelper.ErrorCode
88

99
importGroupherServer.CMS.Delegate.Helper,only:[mark_viewer_emotion_states:3]
10-
importGroupherServer.CMS.Helper.Matcher2
10+
importGroupherServer.CMS.Helper.Matcher
1111
importShortMaps
1212

1313
aliasHelper.Types,as:T
@@ -106,7 +106,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
106106
add_participator_to_article(article,user)
107107
end)
108108
|>Repo.transaction()
109-
|>upsert_comment_result()
109+
|>result()
110110
end
111111
end
112112

@@ -130,7 +130,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
130130
ORM.update(comment,%{body_html:@delete_hint,is_deleted:true})
131131
end)
132132
|>Repo.transaction()
133-
|>upsert_comment_result()
133+
|>result()
134134
end
135135

136136
# add participator to article-like content (Post, Job ...) and update count
@@ -274,16 +274,16 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
274274
Map.merge(paged_comments,%{entries:entries})
275275
end
276276

277-
defpupsert_comment_result({:ok,%{create_article_comment:result}}),do:{:ok,result}
278-
defpupsert_comment_result({:ok,%{delete_article_comment:result}}),do:{:ok,result}
277+
defpresult({:ok,%{create_article_comment:result}}),do:{:ok,result}
278+
defpresult({:ok,%{delete_article_comment:result}}),do:{:ok,result}
279279

280-
defpupsert_comment_result({:error,:create_article_comment,result,_steps})do
280+
defpresult({:error,:create_article_comment,result,_steps})do
281281
raise_error(:create_comment,result)
282282
end
283283

284-
defpupsert_comment_result({:error,:add_participator,result,_steps})do
284+
defpresult({:error,:add_participator,result,_steps})do
285285
{:error,result}
286286
end
287287

288-
defpupsert_comment_result({:error,_,result,_steps}),do:{:error,result}
288+
defpresult({:error,_,result,_steps}),do:{:error,result}
289289
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommentAction do
99
importGroupherServer.CMS.Delegate.ArticleComment,
1010
only:[add_participator_to_article:2,do_create_comment:4,update_article_comments_count:2]
1111

12-
importGroupherServer.CMS.Helper.Matcher2
12+
importGroupherServer.CMS.Helper.Matcher
1313

1414
aliasHelper.Types,as:T
1515
aliasHelper.ORM

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp