mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-10 00:28:22 -05:00
fixed system page
This commit is contained in:
@@ -175,7 +175,7 @@
|
|||||||
{#{% for orphan in orphans %}{{ orphan }}#}
|
{#{% for orphan in orphans %}{{ orphan }}#}
|
||||||
{#{% endfor %}#}
|
{#{% endfor %}#}
|
||||||
{# </textarea>#}
|
{# </textarea>#}
|
||||||
|
{% if api_space_stats %}
|
||||||
<h4 class="mt-3">API Stats</h4>
|
<h4 class="mt-3">API Stats</h4>
|
||||||
<h6 >Space Stats</h6>
|
<h6 >Space Stats</h6>
|
||||||
<table class="table table-bordered table-striped">
|
<table class="table table-bordered table-striped">
|
||||||
@@ -202,7 +202,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
{% endif %}
|
||||||
<h4 class="mt-3">Debug</h4>
|
<h4 class="mt-3">Debug</h4>
|
||||||
<textarea class="form-control" rows="20">
|
<textarea class="form-control" rows="20">
|
||||||
Gunicorn Media: {{ gunicorn_media }}
|
Gunicorn Media: {{ gunicorn_media }}
|
||||||
|
|||||||
@@ -112,35 +112,38 @@ class LoggingMixin(object):
|
|||||||
super(LoggingMixin, self).initial(request, *args, **kwargs)
|
super(LoggingMixin, self).initial(request, *args, **kwargs)
|
||||||
|
|
||||||
if settings.REDIS_HOST:
|
if settings.REDIS_HOST:
|
||||||
d = date.today().isoformat()
|
try:
|
||||||
space = request.space
|
d = date.today().isoformat()
|
||||||
endpoint = request.resolver_match.url_name
|
space = request.space
|
||||||
|
endpoint = request.resolver_match.url_name
|
||||||
|
|
||||||
r = redis.StrictRedis(
|
r = redis.StrictRedis(
|
||||||
host=settings.REDIS_HOST,
|
host=settings.REDIS_HOST,
|
||||||
port=settings.REDIS_PORT,
|
port=settings.REDIS_PORT,
|
||||||
username=settings.REDIS_USERNAME,
|
username=settings.REDIS_USERNAME,
|
||||||
password=settings.REDIS_PASSWORD,
|
password=settings.REDIS_PASSWORD,
|
||||||
db=settings.REDIS_DATABASES['STATS'],
|
db=settings.REDIS_DATABASES['STATS'],
|
||||||
)
|
)
|
||||||
|
|
||||||
pipe = r.pipeline()
|
pipe = r.pipeline()
|
||||||
|
|
||||||
# Global and daily tallies for all URLs.
|
# Global and daily tallies for all URLs.
|
||||||
pipe.incr('api:request-count')
|
pipe.incr('api:request-count')
|
||||||
pipe.incr(f'api:request-count:{d}')
|
pipe.incr(f'api:request-count:{d}')
|
||||||
|
|
||||||
# Use a sorted set to store the user stats, with the score representing
|
# Use a sorted set to store the user stats, with the score representing
|
||||||
# the number of queries the user made total or on a given day.
|
# the number of queries the user made total or on a given day.
|
||||||
pipe.zincrby(f'api:space-request-count', 1, space.pk)
|
pipe.zincrby(f'api:space-request-count', 1, space.pk)
|
||||||
pipe.zincrby(f'api:space-request-count:{d}', 1, space.pk)
|
pipe.zincrby(f'api:space-request-count:{d}', 1, space.pk)
|
||||||
|
|
||||||
# Use a sorted set to store all the endpoints with score representing
|
# Use a sorted set to store all the endpoints with score representing
|
||||||
# the number of queries the endpoint received total or on a given day.
|
# the number of queries the endpoint received total or on a given day.
|
||||||
pipe.zincrby(f'api:endpoint-request-count', 1, endpoint)
|
pipe.zincrby(f'api:endpoint-request-count', 1, endpoint)
|
||||||
pipe.zincrby(f'api:endpoint-request-count:{d}', 1, endpoint)
|
pipe.zincrby(f'api:endpoint-request-count:{d}', 1, endpoint)
|
||||||
|
|
||||||
pipe.execute()
|
pipe.execute()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class StandardFilterMixin(ViewSetMixin):
|
class StandardFilterMixin(ViewSetMixin):
|
||||||
|
|||||||
@@ -346,6 +346,8 @@ def system(request):
|
|||||||
for key in migration_info.keys():
|
for key in migration_info.keys():
|
||||||
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_stats = None
|
||||||
|
api_space_stats = None
|
||||||
# API endpoint logging
|
# API endpoint logging
|
||||||
if settings.REDIS_HOST:
|
if settings.REDIS_HOST:
|
||||||
r = redis.StrictRedis(
|
r = redis.StrictRedis(
|
||||||
|
|||||||
Reference in New Issue
Block a user