mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
fixed system view
This commit is contained in:
@@ -347,41 +347,42 @@ def system(request):
|
|||||||
migration_info[key]['total'] = len(migration_info[key]['unapplied_migrations']) + len(migration_info[key]['applied_migrations'])
|
migration_info[key]['total'] = len(migration_info[key]['unapplied_migrations']) + len(migration_info[key]['applied_migrations'])
|
||||||
|
|
||||||
# API endpoint logging
|
# API endpoint logging
|
||||||
r = redis.StrictRedis(
|
if settings.REDIS_HOST:
|
||||||
host=settings.REDIS_HOST,
|
r = redis.StrictRedis(
|
||||||
port=settings.REDIS_PORT,
|
host=settings.REDIS_HOST,
|
||||||
password='',
|
port=settings.REDIS_PORT,
|
||||||
username='',
|
password='',
|
||||||
db=settings.REDIS_DATABASES['STATS'],
|
username='',
|
||||||
)
|
db=settings.REDIS_DATABASES['STATS'],
|
||||||
|
)
|
||||||
|
|
||||||
api_stats = [['Endpoint', 'Total']]
|
api_stats = [['Endpoint', 'Total']]
|
||||||
api_space_stats = [['User', 'Total']]
|
api_space_stats = [['User', 'Total']]
|
||||||
total_stats = ['All', int(r.get('api:request-count'))]
|
total_stats = ['All', int(r.get('api:request-count'))]
|
||||||
|
|
||||||
for i in range(0, 6):
|
|
||||||
d = (date.today() - timedelta(days=i)).isoformat()
|
|
||||||
api_stats[0].append(d)
|
|
||||||
api_space_stats[0].append(d)
|
|
||||||
total_stats.append(int(r.get(f'api:request-count:{d}')) if r.get(f'api:request-count:{d}') else 0)
|
|
||||||
|
|
||||||
api_stats.append(total_stats)
|
|
||||||
|
|
||||||
for x in r.zrange('api:endpoint-request-count', 0, -1, withscores=True, desc=True):
|
|
||||||
endpoint = x[0].decode('utf-8')
|
|
||||||
endpoint_stats = [endpoint, x[1]]
|
|
||||||
for i in range(0, 6):
|
for i in range(0, 6):
|
||||||
d = (date.today() - timedelta(days=i)).isoformat()
|
d = (date.today() - timedelta(days=i)).isoformat()
|
||||||
endpoint_stats.append(r.zscore(f'api:endpoint-request-count:{d}', endpoint))
|
api_stats[0].append(d)
|
||||||
api_stats.append(endpoint_stats)
|
api_space_stats[0].append(d)
|
||||||
|
total_stats.append(int(r.get(f'api:request-count:{d}')) if r.get(f'api:request-count:{d}') else 0)
|
||||||
|
|
||||||
for x in r.zrange('api:space-request-count', 0, 20, withscores=True, desc=True):
|
api_stats.append(total_stats)
|
||||||
s = x[0].decode('utf-8')
|
|
||||||
space_stats = [Space.objects.get(pk=s).name, x[1]]
|
for x in r.zrange('api:endpoint-request-count', 0, -1, withscores=True, desc=True):
|
||||||
for i in range(0, 6):
|
endpoint = x[0].decode('utf-8')
|
||||||
d = (date.today() - timedelta(days=i)).isoformat()
|
endpoint_stats = [endpoint, x[1]]
|
||||||
space_stats.append(r.zscore(f'api:space-request-count:{d}', s))
|
for i in range(0, 6):
|
||||||
api_space_stats.append(space_stats)
|
d = (date.today() - timedelta(days=i)).isoformat()
|
||||||
|
endpoint_stats.append(r.zscore(f'api:endpoint-request-count:{d}', endpoint))
|
||||||
|
api_stats.append(endpoint_stats)
|
||||||
|
|
||||||
|
for x in r.zrange('api:space-request-count', 0, 20, withscores=True, desc=True):
|
||||||
|
s = x[0].decode('utf-8')
|
||||||
|
space_stats = [Space.objects.get(pk=s).name, x[1]]
|
||||||
|
for i in range(0, 6):
|
||||||
|
d = (date.today() - timedelta(days=i)).isoformat()
|
||||||
|
space_stats.append(r.zscore(f'api:space-request-count:{d}', s))
|
||||||
|
api_space_stats.append(space_stats)
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request, 'system.html', {
|
request, 'system.html', {
|
||||||
|
|||||||
Reference in New Issue
Block a user