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.

Commitb4a3abf

Browse files
committed
fix(commentsParticipators): tmp fix for issue#16
1 parentc8bc3f2 commitb4a3abf

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

‎lib/groupher_server/cms/utils/loader.ex‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ defmodule GroupherServer.CMS.Utils.Loader do
181181
defquery({"posts_comments",PostComment},%{filter:filter,unique:true})do
182182
PostComment
183183
|>join(:inner,[c],ainassoc(c,:author))
184-
|>distinct([c,a],a.id)
184+
# NOTE: this distinct not working in production env, so the uniq logic is move to
185+
# cut_participators.ex middleware, when the data is large, will cause performace issue
186+
# |> distinct([c, a], a.id)
185187
|>select([c,a],a)
186188

187189
# |> select([c, a], %{

‎lib/groupher_server_web/middleware/cut_participators.ex‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ defmodule GroupherServerWeb.Middleware.CutParticipators do
88
# should use WINDOW function
99
# see https://github.com/coderplanets/coderplanets_server/issues/16
1010
#
11+
# the Enum.uniq logic is a tmp sulution for distinct comments users, this should be
12+
# in dataloader logic, but the distinct is not working in production env
1113
"""
1214

1315
@behaviourAbsinthe.Middleware
@@ -16,11 +18,14 @@ defmodule GroupherServerWeb.Middleware.CutParticipators do
1618
defcall(%{errors:errors}=resolution,_)whenlength(errors)>0,do:resolution
1719

1820
defcall(%{value:value,arguments:%{filter:%{first:first}}=args}=resolution,_)do
19-
%{resolution|value:value|>Enum.reverse()|>Enum.slice(0,first)}
21+
%{resolution|value:value|>Enum.uniq()|>Enum.reverse()|>Enum.slice(0,first)}
2022
end
2123

2224
defcall(%{value:value}=resolution,_)do
23-
%{resolution|value:value|>Enum.reverse()|>Enum.slice(0,@default_length)}
25+
%{
26+
resolution
27+
|value:value|>Enum.uniq()|>Enum.reverse()|>Enum.slice(0,@default_length)
28+
}
2429
end
2530

2631
defcall(resolution,_),do:resolution

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp