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.

Commit8a8c7e1

Browse files
authored
refactor: user/works page debug (#438)
* refactor(user-model): add/remove social fields* refactor(user): user profile & works cover staff* fix(account): unused embeds dir* chore: workss -> works* fix: import error* fix(community-meta): plural errror
1 parente700c36 commit8a8c7e1

File tree

35 files changed

+166
-243
lines changed

35 files changed

+166
-243
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ defmodule GroupherServer.Accounts.Delegate.Profile do
88

99
aliasGroupherServer.{Accounts,CMS,Email,Repo,Statistics}
1010

11-
aliasAccounts.Model.{Achievement,GithubUser,User,Social}
11+
aliasAccounts.Model.{Achievement,GithubUser,User,Social,Embeds}
1212
aliasCMS.Model.{Community,CommunitySubscriber}
1313

1414
aliasGroupherServer.Accounts.Delegate.Fans
1515

1616
aliasHelper.{Guardian,ORM,QueryBuilder,RadarSearch}
1717
aliasEcto.Multi
1818

19+
@default_user_metaEmbeds.UserMeta.default_meta()
1920
@default_subscribed_communitiesget_config(:general,:default_subscribed_communities)
2021

2122
defread_user(login)whenis_binary(login)do
22-
with{:ok,user}<-ORM.read_by(User,%{login:login},inc::views)do
23+
with{:ok,user}<-ORM.read_by(User,%{login:login},inc::views),
24+
{:ok,user}<-assign_meta_ifneed(user)do
2325
caseuser.contributesdo
2426
nil->assign_default_contributes(user)
2527
_->{:ok,user}
@@ -46,6 +48,14 @@ defmodule GroupherServer.Accounts.Delegate.Profile do
4648
end
4749
end
4850

51+
defpassign_meta_ifneed(%User{meta:nil}=user)do
52+
{:ok,Map.merge(user,%{meta:@default_user_meta})}
53+
end
54+
55+
defpassign_meta_ifneed(user)do
56+
{:ok,user}
57+
end
58+
4959
defpaged_users(filter,%User{}=user)do
5060
ORM.find_all(User,filter)|>Fans.mark_viewer_follow_status(user)|>done
5161
end

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule GroupherServer.Accounts.Delegate.Publish do
33
user followers / following related
44
"""
55
importEcto.Query,warn:false
6-
importHelper.Utils,only:[ensure:2]
6+
importHelper.Utils,only:[ensure:2,plural:1]
77

88
aliasGroupherServer.{Accounts,CMS}
99
aliasAccounts.Model.{Embeds,User}
@@ -29,7 +29,7 @@ defmodule GroupherServer.Accounts.Delegate.Publish do
2929
{:ok,paged_articles}<-CMS.paged_published_articles(thread,filter,user_id)do
3030
#
3131
user_meta=ensure(user.meta,@default_meta)
32-
meta=Map.put(user_meta,:"published_#{thread}s_count",paged_articles.total_count)
32+
meta=Map.put(user_meta,:"published_#{plural(thread)}_count",paged_articles.total_count)
3333

3434
ORM.update_meta(user,meta)
3535
end

‎lib/groupher_server/accounts/embeds/collect_folder_meta.ex‎

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

‎lib/groupher_server/accounts/embeds/user_contribute.ex‎

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

‎lib/groupher_server/accounts/embeds/user_contribute_record.ex‎

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

‎lib/groupher_server/accounts/embeds/user_meta.ex‎

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

‎lib/groupher_server/accounts/models/embeds/user_contribute.ex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule GroupherServer.Accounts.Model.Embeds.UserContribute do
66
useAccessible
77
importEcto.Changeset
88

9-
aliasGroupherServer.Accounts.Embeds
9+
aliasGroupherServer.Accounts.Model.Embeds
1010

1111
@optional_fields~w(reported_count)a
1212

‎lib/groupher_server/accounts/models/embeds/user_meta.ex‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
defmoduleGroupherServer.Accounts.Model.Embeds.UserMeta.Macrodo
22
@moduledocfalse
33

4-
importHelper.Utils,only:[get_config:2]
4+
importHelper.Utils,only:[get_config:2,plural:1]
55

66
@article_threadsget_config(:article,:threads)
77

88
defmacropublished_article_count_fields()do
99
@article_threads
1010
|>Enum.map(fnthread->
1111
quotedo
12-
field(unquote(:"published_#{thread}s_count"),:integer,default:0)
12+
field(unquote(:"published_#{plural(thread)}_count"),:integer,default:0)
1313
end
1414
end)
1515
end
@@ -23,8 +23,8 @@ defmodule GroupherServer.Accounts.Model.Embeds.UserMeta do
2323
useAccessible
2424

2525
importEcto.Changeset
26-
importGroupherServer.Accounts.Embeds.UserMeta.Macro
27-
importHelper.Utils,only:[get_config:2]
26+
importGroupherServer.Accounts.Model.Embeds.UserMeta.Macro
27+
importHelper.Utils,only:[get_config:2,plural:1]
2828

2929
@article_threadsget_config(:article,:threads)
3030

@@ -36,12 +36,12 @@ defmodule GroupherServer.Accounts.Model.Embeds.UserMeta do
3636
}
3737

3838
@optional_fieldsMap.keys(@general_options)++
39-
Enum.map(@article_threads,&:"published_#{&1}s_count")
39+
Enum.map(@article_threads,&:"published_#{plural(&1)}_count")
4040

4141
defdefault_meta()do
4242
published_article_counts=
4343
@article_threads
44-
|>Enum.reduce([],&(&2++["published_#{&1}s_count":0]))
44+
|>Enum.reduce([],&(&2++["published_#{plural(&1)}_count":0]))
4545
|>Enum.into(%{})
4646

4747
@general_options|>Map.merge(published_article_counts)

‎lib/groupher_server/accounts/models/social.ex‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,22 @@ defmodule GroupherServer.Accounts.Model.Social do
88
aliasGroupherServer.Accounts.Model.User
99

1010
@required_fields~w(user_id)a
11-
@optional_fields~w(github twitterfacebookzhihu dribble huaban douban pinterest instagram qq weichat weibo)a
11+
@optional_fields~w(github twitterblog companyzhihu dribble huaban douban pinterest)a
1212

1313
@typet::%Social{}
1414
schema"user_socials"do
1515
belongs_to(:user,User)
1616

1717
field(:github,:string)
1818
field(:twitter,:string)
19-
field(:facebook,:string)
19+
field(:blog,:string)
20+
field(:company,:string)
2021
field(:zhihu,:string)
2122
field(:dribble,:string)
2223
field(:huaban,:string)
2324
field(:douban,:string)
2425

2526
field(:pinterest,:string)
26-
field(:instagram,:string)
27-
28-
field(:qq,:string)
29-
field(:weichat,:string)
30-
field(:weibo,:string)
31-
3227
# timestamps(type: :utc_datetime)
3328
end
3429

‎lib/groupher_server/accounts/models/user.ex‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ defmodule GroupherServer.Accounts.Model.User do
2525
aliasGroupherServer.CMS.Model.{Passport,CommunitySubscriber}
2626

2727
@required_fields~w(nickname avatar)a
28-
@optional_fields~w(login nickname bio remote_ip sex location email subscribed_communities_count)a
28+
@optional_fields~w(login nickname bioshortbioremote_ip sex location email subscribed_communities_count)a
2929

3030
@typet::%User{}
3131
schema"users"do
@@ -34,6 +34,7 @@ defmodule GroupherServer.Accounts.Model.User do
3434
field(:avatar,:string)
3535
field(:sex,:string)
3636
field(:bio,:string)
37+
field(:shortbio,:string)
3738
field(:email,:string)
3839
field(:location,:string)
3940
field(:from_github,:boolean)
@@ -104,9 +105,5 @@ defmodule GroupherServer.Accounts.Model.User do
104105
|>validate_inclusion(:sex,["dude","girl"])
105106
|>validate_format(:email,~r/@/)
106107
|>validate_length(:location,min:2,max:30)
107-
108-
# |> validate_length(:qq, min: 8, max: 15)
109-
# |> validate_length(:weichat, min: 3, max: 30)
110-
# |> validate_length(:weibo, min: 3, max: 30)
111108
end
112109
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp