1
1
# 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 ,
3
3
algorithm, times
4
4
5
5
type
10
10
Sponsor = object
11
11
name, url, logo: string
12
12
amount, allTime: float
13
- since: TimeInfo
13
+ since: DateTime
14
14
level: int # TODO : Change to enum?
15
15
16
16
const
@@ -113,7 +113,7 @@ proc processSupporters(supporters: JsonNode) =
113
113
echo (" Found " , supporters.elems.len, " named sponsors." )
114
114
115
115
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 )
117
117
)
118
118
119
119
@@ -125,9 +125,9 @@ proc quote(text: string): string =
125
125
126
126
proc getLevel (supporter: JsonNode ): int =
127
127
if supporter.hasKey (" level" ):
128
- return supporter[" level" ].getNum ().int
128
+ return supporter[" level" ].getInt ().int
129
129
130
- let amount = supporter[" monthly_amount" ].getFNum ()
130
+ let amount = supporter[" monthly_amount" ].getFloat ()
131
131
const levels = [250 , 150 , 75 , 25 , 10 , 5 , 1 , 0 ]
132
132
result = levels[0 ]
133
133
for i in levels:
@@ -183,7 +183,7 @@ when isMainModule:
183
183
if url.len > 0 and not url.startsWith (" http" ):
184
184
url = " http://" & url
185
185
186
- let amount = supporter[" monthly_amount" ].getFNum ()
186
+ let amount = supporter[" monthly_amount" ].getFloat ()
187
187
# Only show URL when user donated at least $5.
188
188
if amount < 5 :
189
189
url = " "
@@ -193,11 +193,11 @@ when isMainModule:
193
193
logo = supporter[" image_url_large" ].getStr ()
194
194
195
195
let sponsor = Sponsor (name: name, url: url, logo: logo, amount: amount,
196
- allTime: supporter[" alltime_amount" ].getFNum (),
196
+ allTime: supporter[" alltime_amount" ].getFloat (),
197
197
since: parse (supporter[" created_at" ].getStr[0 .. 18 ], " yyyy-MM-dd'T'hh:mm:ss" ),
198
198
level: getLevel (supporter)
199
199
)
200
- if supporter[" monthly_amount" ].getFNum > 0.0 :
200
+ if supporter[" monthly_amount" ].getFloat > 0.0 :
201
201
activeSponsors.add (sponsor)
202
202
else :
203
203
inactiveSponsors.add (sponsor)
@@ -209,4 +209,4 @@ when isMainModule:
209
209
210
210
echo (" Make sure that the new csv files don't lose any data, then copy them " &
211
211
" into the _data directory. (Remember to rename them to remove the .new " &
212
- " suffix." )
212
+ " suffix." )
0 commit comments