From 77e0bae8be8c7dc1033a5ac4da9bcb5948d5778b Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Wed, 1 Jan 2025 13:26:36 -0500 Subject: [PATCH] Refactor Redis stats retrieval to use django-redis and improve code readability --- website/views/core.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/website/views/core.py b/website/views/core.py index 291456504..84abf804a 100644 --- a/website/views/core.py +++ b/website/views/core.py @@ -31,6 +31,7 @@ from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_GET from django.views.generic import TemplateView, View +from django_redis import get_redis_connection from requests.auth import HTTPBasicAuth from rest_framework import status from rest_framework.decorators import api_view @@ -155,8 +156,8 @@ def check_status(request): # Get database connection count status["db_connection_count"] = len(connection.queries) - # Get Redis stats - redis_client = redis.StrictRedis(host="localhost", port=6379, db=0) + # Get Redis stats using django-redis + redis_client = get_redis_connection("default") status["redis_stats"] = redis_client.info() # Add memory profiling information @@ -677,9 +678,6 @@ def robots_txt(request): return HttpResponse("\n".join(lines), content_type="text/plain") -import os - - def get_last_commit_date(): try: return (