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.

Commit70cf4e3

Browse files
committed
fix(active_at): adjust lock_article_comment arg & fmt
1 parent0efe9f5 commit70cf4e3

File tree

7 files changed

+28
-31
lines changed

7 files changed

+28
-31
lines changed

‎lib/groupher_server/cms/cms.ex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ defmodule GroupherServer.CMS do
116116
# >> set flag on article, like: pin / unpin article
117117
defdelegatepin_article(thread,id,community_id),to:ArticleCommunity
118118
defdelegateundo_pin_article(thread,id,community_id),to:ArticleCommunity
119-
defdelegatelock_article_comment(article),to:ArticleCommunity
119+
defdelegatelock_article_comment(thread,article_id),to:ArticleCommunity
120120

121121
# >> community: set / unset
122122
defdelegatemirror_article(thread,article_id,community_id),to:ArticleCommunity

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommunity do
66
importEcto.Query,warn:false
77

88
importHelper.ErrorCode
9-
importHelper.Utils,only:[strip_struct:1,done:1]
9+
importHelper.Utils,only:[strip_struct:1,done:1,ensure:2]
1010
importGroupherServer.CMS.Helper.Matcher
1111

1212
aliasHelper.Types,as:T
@@ -17,6 +17,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommunity do
1717

1818
aliasEcto.Multi
1919

20+
@default_article_metaEmbeds.ArticleMeta.default_meta()
2021
@max_pinned_article_count_per_threadCommunity.max_pinned_article_count_per_thread()
2122

2223
@specpin_article(T.article_thread(),Integer.t(),Integer.t())::{:ok,PinnedArticle.t()}
@@ -144,21 +145,16 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommunity do
144145
defupdate_edit_status(content,_),do:{:ok,content}
145146

146147
@doc"lock comment of a article"
147-
# TODO: record it to ArticleLog
148-
deflock_article_comment(
149-
%{meta:%Embeds.ArticleMeta{is_comment_locked:false}=meta}=content
150-
)do
151-
meta=
152-
meta
153-
|>Map.from_struct()
154-
|>Map.delete(:id)
155-
|>Map.merge(%{is_comment_locked:true})
148+
deflock_article_comment(thread,id)do
149+
with{:ok,info}<-match(thread),
150+
{:ok,article}<-ORM.find(info.model,id)do
151+
article_meta=ensure(article.meta,@default_article_meta)
152+
meta=Map.merge(article_meta,%{is_comment_locked:true})
156153

157-
ORM.update_meta(content,meta)
154+
ORM.update_meta(article,meta)
155+
end
158156
end
159157

160-
deflock_article_comment(content),do:{:ok,content}
161-
162158
# check if the thread has aready enough pinned articles
163159
defpcheck_pinned_article_count(community_id,thread)do
164160
thread_upcase=thread|>to_string|>String.upcase()

‎test/groupher_server/cms/articles/job_test.exs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ defmodule GroupherServer.Test.Articles.Job do
9595
end
9696

9797
describe"[cms job sink/undo_sink]"do
98-
@tag:wip
98+
@tag:wip2
9999
test"if a job is too old, read job should update can_undo_sink flag",
100100
~m(user community job_attrs)ado
101101
{:ok,job}=CMS.create_article(community,:job,job_attrs,user)
@@ -110,7 +110,7 @@ defmodule GroupherServer.Test.Articles.Job do
110110
assertnotjob_last_year.meta.can_undo_sink
111111
end
112112

113-
@tag:wip
113+
@tag:wip2
114114
test"can sink a job",~m(user community job_attrs)ado
115115
{:ok,job}=CMS.create_article(community,:job,job_attrs,user)
116116
assertnotjob.meta.is_sinked
@@ -120,7 +120,7 @@ defmodule GroupherServer.Test.Articles.Job do
120120
assertjob.active_at==job.inserted_at
121121
end
122122

123-
@tag:wip
123+
@tag:wip2
124124
test"can undo sink job",~m(user community job_attrs)ado
125125
{:ok,job}=CMS.create_article(community,:job,job_attrs,user)
126126
{:ok,job}=CMS.sink_article(:job,job.id)
@@ -132,7 +132,7 @@ defmodule GroupherServer.Test.Articles.Job do
132132
assertjob.active_at==job.meta.last_active_at
133133
end
134134

135-
@tag:wip
135+
@tag:wip2
136136
test"can not undo sink to old job",~m()ado
137137
{:ok,job_last_year}=db_insert(:job,%{title:"last year",inserted_at:@last_year})
138138

‎test/groupher_server/cms/articles/post_meta_test.exs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ defmodule GroupherServer.Test.CMS.PostMeta do
4242
assertpost.meta.is_edited
4343
end
4444

45-
test"post 's lock article should work",~m(user community post_attrs)ado
45+
@tag:wip
46+
test"post's lock article should work",~m(user community post_attrs)ado
4647
{:ok,post}=CMS.create_article(community,:post,post_attrs,user)
4748
assertnotpost.meta.is_comment_locked
4849

49-
{:ok,_}=CMS.lock_article_comment(post)
50+
{:ok,_}=CMS.lock_article_comment(:post,post.id)
5051
{:ok,post}=ORM.find_by(Post,id:post.id)
5152

5253
assertpost.meta.is_comment_locked

‎test/groupher_server/cms/articles/post_test.exs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ defmodule GroupherServer.Test.CMS.Articles.Post do
105105
end
106106

107107
describe"[cms post sink/undo_sink]"do
108-
@tag:wip
108+
@tag:wip2
109109
test"if a post is too old, read post should update can_undo_sink flag",
110110
~m(user community post_attrs)ado
111111
{:ok,post}=CMS.create_article(community,:post,post_attrs,user)
@@ -120,7 +120,7 @@ defmodule GroupherServer.Test.CMS.Articles.Post do
120120
assertnotpost_last_year.meta.can_undo_sink
121121
end
122122

123-
@tag:wip
123+
@tag:wip2
124124
test"can sink a post",~m(user community post_attrs)ado
125125
{:ok,post}=CMS.create_article(community,:post,post_attrs,user)
126126
assertnotpost.meta.is_sinked
@@ -130,7 +130,7 @@ defmodule GroupherServer.Test.CMS.Articles.Post do
130130
assertpost.active_at==post.inserted_at
131131
end
132132

133-
@tag:wip
133+
@tag:wip2
134134
test"can undo sink post",~m(user community post_attrs)ado
135135
{:ok,post}=CMS.create_article(community,:post,post_attrs,user)
136136
{:ok,post}=CMS.sink_article(:post,post.id)
@@ -142,7 +142,7 @@ defmodule GroupherServer.Test.CMS.Articles.Post do
142142
assertpost.active_at==post.meta.last_active_at
143143
end
144144

145-
@tag:wip
145+
@tag:wip2
146146
test"can not undo sink to old post",~m()ado
147147
{:ok,post_last_year}=db_insert(:post,%{title:"last year",inserted_at:@last_year})
148148

‎test/groupher_server/cms/articles/repo_test.exs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ defmodule GroupherServer.Test.Articles.Repo do
106106
end
107107

108108
describe"[cms repo sink/undo_sink]"do
109-
@tag:wip
109+
@tag:wip2
110110
test"if a repo is too old, read repo should update can_undo_sink flag",
111111
~m(user community repo_attrs)ado
112112
{:ok,repo}=CMS.create_article(community,:repo,repo_attrs,user)
@@ -121,7 +121,7 @@ defmodule GroupherServer.Test.Articles.Repo do
121121
assertnotrepo_last_year.meta.can_undo_sink
122122
end
123123

124-
@tag:wip
124+
@tag:wip2
125125
test"can sink a repo",~m(user community repo_attrs)ado
126126
{:ok,repo}=CMS.create_article(community,:repo,repo_attrs,user)
127127
assertnotrepo.meta.is_sinked
@@ -131,7 +131,7 @@ defmodule GroupherServer.Test.Articles.Repo do
131131
assertrepo.active_at==repo.inserted_at
132132
end
133133

134-
@tag:wip
134+
@tag:wip2
135135
test"can undo sink repo",~m(user community repo_attrs)ado
136136
{:ok,repo}=CMS.create_article(community,:repo,repo_attrs,user)
137137
{:ok,repo}=CMS.sink_article(:repo,repo.id)
@@ -143,7 +143,7 @@ defmodule GroupherServer.Test.Articles.Repo do
143143
assertrepo.active_at==repo.meta.last_active_at
144144
end
145145

146-
@tag:wip
146+
@tag:wip2
147147
test"can not undo sink to old repo",~m()ado
148148
{:ok,repo_last_year}=db_insert(:repo,%{title:"last year",inserted_at:@last_year})
149149

‎test/groupher_server_web/query/cms/paged_articles/paged_posts_test.exs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ defmodule GroupherServer.Test.Query.PagedArticles.PagedPosts do
315315
}
316316
}
317317
"""
318-
@tag:wip
318+
@tag:wip2
319319
test"latest commented post should appear on top",~m(guest_conn post_last_week user)ado
320320
variables=%{filter:%{page:1,size:20}}
321321
results=guest_conn|>query_result(@query,variables,"pagedPosts")
@@ -333,7 +333,7 @@ defmodule GroupherServer.Test.Query.PagedArticles.PagedPosts do
333333
assertfirst_post["id"]==to_string(post_last_week.id)
334334
end
335335

336-
@tag:wip
336+
@tag:wip2
337337
test"comment on very old post have no effect",~m(guest_conn post_last_year user)ado
338338
variables=%{filter:%{page:1,size:20}}
339339

@@ -346,7 +346,7 @@ defmodule GroupherServer.Test.Query.PagedArticles.PagedPosts do
346346
assertfirst_post["id"]!==to_string(post_last_year.id)
347347
end
348348

349-
@tag:wip
349+
@tag:wip2
350350
test"latest post author commented post have no effect",~m(guest_conn post_last_week)ado
351351
variables=%{filter:%{page:1,size:20}}
352352

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp