Skip to content

Commit 67b5a8b

Browse files
committed
update the bountysource script
1 parent 80a5ae9 commit 67b5a8b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

scripts/bountysource.nim

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Based on bountysource.cr located at https://github.com/crystal-lang/crystal-website/blob/master/scripts/bountysource.cr
2-
import httpclient, asyncdispatch, json, strutils, os, strtabs, sequtils, future,
2+
import httpclient, asyncdispatch, json, strutils, os, strtabs, sequtils, sugar,
33
algorithm, times
44

55
type
@@ -10,7 +10,7 @@ type
1010
Sponsor = object
1111
name, url, logo: string
1212
amount, allTime: float
13-
since: TimeInfo
13+
since: DateTime
1414
level: int # TODO: Change to enum?
1515

1616
const
@@ -113,7 +113,7 @@ proc processSupporters(supporters: JsonNode) =
113113
echo("Found ", supporters.elems.len, " named sponsors.")
114114

115115
supporters.elems.sort(
116-
(x, y) => cmp(y["alltime_amount"].getFNum, x["alltime_amount"].getFNum)
116+
(x, y) => cmp(y["alltime_amount"].getFloat, x["alltime_amount"].getFloat)
117117
)
118118

119119

@@ -125,9 +125,9 @@ proc quote(text: string): string =
125125

126126
proc getLevel(supporter: JsonNode): int =
127127
if supporter.hasKey("level"):
128-
return supporter["level"].getNum().int
128+
return supporter["level"].getInt().int
129129

130-
let amount = supporter["monthly_amount"].getFNum()
130+
let amount = supporter["monthly_amount"].getFloat()
131131
const levels = [250, 150, 75, 25, 10, 5, 1, 0]
132132
result = levels[0]
133133
for i in levels:
@@ -183,7 +183,7 @@ when isMainModule:
183183
if url.len > 0 and not url.startsWith("http"):
184184
url = "http://" & url
185185

186-
let amount = supporter["monthly_amount"].getFNum()
186+
let amount = supporter["monthly_amount"].getFloat()
187187
# Only show URL when user donated at least $5.
188188
if amount < 5:
189189
url = ""
@@ -193,11 +193,11 @@ when isMainModule:
193193
logo = supporter["image_url_large"].getStr()
194194

195195
let sponsor = Sponsor(name: name, url: url, logo: logo, amount: amount,
196-
allTime: supporter["alltime_amount"].getFNum(),
196+
allTime: supporter["alltime_amount"].getFloat(),
197197
since: parse(supporter["created_at"].getStr[0 .. 18], "yyyy-MM-dd'T'hh:mm:ss"),
198198
level: getLevel(supporter)
199199
)
200-
if supporter["monthly_amount"].getFNum > 0.0:
200+
if supporter["monthly_amount"].getFloat > 0.0:
201201
activeSponsors.add(sponsor)
202202
else:
203203
inactiveSponsors.add(sponsor)
@@ -209,4 +209,4 @@ when isMainModule:
209209

210210
echo("Make sure that the new csv files don't lose any data, then copy them " &
211211
"into the _data directory. (Remember to rename them to remove the .new "&
212-
"suffix.")
212+
"suffix.")

0 commit comments

Comments
 (0)