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.

Commit85f7b2e

Browse files
committed
make it readable
1 parent02b1a39 commit85f7b2e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

‎lib/mastani_server/statistics/statistics.ex‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,21 @@ defmodule MastaniServer.Statistics do
8989
end)
9090
end
9191

92+
# 返回 count 数组,方便前端绘图
93+
# example:
94+
# from: [0,0,0,0,0,0]
95+
# to: [0,30,3,8,0,0]
96+
# 如果 7 天都有 count, 不用计算直接 map 返回
9297
defpto_counts_digest(record,days:count)do
93-
# 如果 7 天都有 count, 不用计算直接 map 返回
9498
caselength(record)==@community_contribute_days+1do
9599
true->
96100
Enum.map(record,&&1.count)
97101

98102
false->
99103
today=Timex.today()|>Date.to_erl()
100-
result=repeat(abs(count)+1,0)|>List.to_tuple()
104+
enmpty_tuple=repeat(abs(count)+1,0)|>List.to_tuple()
101105

102-
Enum.reduce(record,result,fnrecord,acc->
106+
Enum.reduce(record,enmpty_tuple,fnrecord,acc->
103107
diff=Timex.diff(Timex.to_date(record.date),today,:days)
104108
index=diff+abs(count)
105109

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp