Skip to content

Commit

Permalink
Refactor database connection count retrieval and improve code readabi…
Browse files Browse the repository at this point in the history
…lity in core views
  • Loading branch information
DonnieBLT committed Jan 1, 2025
1 parent 77e0bae commit 3ed77c0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion website/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def check_status(request):
)[:5]

# Get database connection count
status["db_connection_count"] = len(connection.queries)
with connection.cursor() as cursor:
cursor.execute("SELECT COUNT(*) FROM pg_stat_activity WHERE state = 'active'")
status["db_connection_count"] = cursor.fetchone()[0]

# Get Redis stats using django-redis
redis_client = get_redis_connection("default")
Expand Down

0 comments on commit 3ed77c0

Please sign in to comment.