def overview(self): return self.render( 'admin/stats/overview.html', active_user_count=AccessLog.active_user_count(), top_downloaders=AccessLog.top_downloaders(10), token_actions=TokenLog.list(10)[0], )
def decorated(*args, **kwargs): response = f(*args, **kwargs) if response.status_code in (200, 307): ip_addr = request.environ.get('REMOTE_ADDR', None) if not ip_addr: ip_addr = request.remote_addr AccessLog.create_record(request.args.get('token'), ip_addr) return response
def decorated(*args, **kwargs): response = f(*args, **kwargs) if response.status_code in (200, 307): if 'BEHIND_GATEWAY' in current_app.config and current_app.config['BEHIND_GATEWAY']: ip_addr = request.headers.get(current_app.config['REMOTE_ADDR_HEADER']) else: ip_addr = request.remote_addr AccessLog.create_record(request.args.get('token'), ip_addr) return response
def decorated(*args, **kwargs): response = f(*args, **kwargs) if response.status_code in (200, 307): if 'BEHIND_GATEWAY' in current_app.config and current_app.config[ 'BEHIND_GATEWAY']: ip_addr = request.headers.get( current_app.config['REMOTE_ADDR_HEADER']) else: ip_addr = request.remote_addr AccessLog.create_record(request.args.get('token'), ip_addr) return response
def hourly_usage_data(self): stats = AccessLog.get_hourly_usage() return Response(json.dumps([{ 'data': [[time.mktime(i[0].utctimetuple()) * 1000, i[1]] for i in stats] }]), content_type='application/json; charset=utf-8')
def hourly_usage_data(self): stats = AccessLog.get_hourly_usage() return Response(json.dumps([{'data': [[ time.mktime(i[0].utctimetuple()) * 1000, i[1] ] for i in stats]}]), content_type='application/json; charset=utf-8')
def top_tokens(self): non_commercial, commercial = AccessLog.top_tokens(limit=100, days=7) return self.render( 'admin/stats/top-tokens.html', non_commercial=non_commercial, commercial=commercial )
def top_ips(self): non_commercial, commercial = AccessLog.top_ips(limit=100, days=7) non_commercial = StatsView.lookup_ips(non_commercial) commercial = StatsView.lookup_ips(commercial) return self.render( 'admin/stats/top-ips.html', non_commercial=non_commercial, commercial=commercial )
def top_tokens(self): days = 7 try: days = int(request.args.get('days')) except: pass non_commercial, commercial = AccessLog.top_tokens(limit=100, days=days) return self.render('admin/stats/top-tokens.html', non_commercial=non_commercial, commercial=commercial, days=days)
def top_ips(self): days = 7 try: days = int(request.args.get('days')) except: pass non_commercial, commercial = AccessLog.top_ips(limit=100, days=days) non_commercial = StatsView.lookup_ips(non_commercial) commercial = StatsView.lookup_ips(commercial) return self.render('admin/stats/top-ips.html', non_commercial=non_commercial, commercial=commercial, days=days)
def cleanup_logs(): with create_app().app_context(): AccessLog.remove_old_ip_addr_records()