20
20
import json
21
21
import socket
22
22
23
+ from metabrainz .utils import get_int_query_param
24
+
23
25
24
26
class HomeView (AdminIndexView ):
25
27
@@ -193,7 +195,7 @@ class CommercialUsersView(AdminBaseView):
193
195
194
196
@expose ('/' )
195
197
def index (self ):
196
- page = int ( request . args . get ( 'page' , default = 1 ) )
198
+ page = get_int_query_param ( 'page' , default = 1 )
197
199
if page < 1 :
198
200
return redirect (url_for ('.index' ))
199
201
limit = 20
@@ -207,7 +209,7 @@ class PaymentsView(AdminBaseView):
207
209
208
210
@expose ('/' )
209
211
def list (self ):
210
- page = int ( request . args . get ( 'page' , default = 1 ) )
212
+ page = get_int_query_param ( 'page' , default = 1 )
211
213
is_donation_arg = request .args .get ('is_donation' )
212
214
if is_donation_arg == "True" :
213
215
is_donation = True
@@ -283,12 +285,7 @@ def lookup_ips(users):
283
285
284
286
@expose ('/top-ips/' )
285
287
def top_ips (self ):
286
-
287
- days = 7
288
- try :
289
- days = int (request .args .get ('days' ))
290
- except :
291
- pass
288
+ days = get_int_query_param ('days' , default = 7 )
292
289
293
290
non_commercial , commercial = AccessLog .top_ips (limit = 100 , days = days )
294
291
@@ -302,15 +299,9 @@ def top_ips(self):
302
299
days = days
303
300
)
304
301
305
-
306
302
@expose ('/top-tokens/' )
307
303
def top_tokens (self ):
308
-
309
- days = 7
310
- try :
311
- days = int (request .args .get ('days' ))
312
- except :
313
- pass
304
+ days = get_int_query_param ('days' , default = 7 )
314
305
315
306
non_commercial , commercial = AccessLog .top_tokens (limit = 100 , days = days )
316
307
return self .render (
@@ -323,7 +314,7 @@ def top_tokens(self):
323
314
324
315
@expose ('/token-log' )
325
316
def token_log (self ):
326
- page = int ( request . args . get ( 'page' , default = 1 ) )
317
+ page = get_int_query_param ( 'page' , default = 1 )
327
318
if page < 1 :
328
319
return redirect (url_for ('.token_log' ))
329
320
limit = 20
0 commit comments