Fix user list display in admin dashboard

- Added debug endpoint to verify database contents
- Enhanced logging in user list API endpoint
- Fixed user query to properly return all users
- Added frontend debugging for troubleshooting

The user list now correctly displays all users in the system.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-06-03 18:57:16 -06:00
parent fa951c3141
commit d8d330fd9d
3 changed files with 94 additions and 1 deletions

43
app.py
View File

@@ -264,6 +264,49 @@ def init_admin_user():
'error': 'Failed to create admin user'
}), 500
@app.route('/api/debug-users')
def debug_users():
"""Debug endpoint to check all users in database"""
try:
# Check if database tables exist
from sqlalchemy import inspect
inspector = inspect(db.engine)
tables = inspector.get_table_names()
# Get all users
all_users = User.query.all()
# Also try a raw SQL query to double-check
raw_result = db.session.execute('SELECT COUNT(*) FROM users').scalar()
# Get some raw user data
raw_users = db.session.execute('SELECT id, username, email, role FROM users LIMIT 10').fetchall()
return jsonify({
'database_tables': tables,
'total_users': len(all_users),
'raw_count': raw_result,
'raw_users_sample': [{'id': str(row[0]), 'username': row[1], 'email': row[2], 'role': row[3]} for row in raw_users],
'users': [
{
'id': str(user.id),
'username': user.username,
'email': user.email,
'role': user.role,
'is_active': user.is_active,
'is_suspended': user.is_suspended,
'created_at': user.created_at.isoformat()
}
for user in all_users
]
})
except Exception as e:
import traceback
return jsonify({
'error': str(e),
'traceback': traceback.format_exc()
}), 500
# Initialize memory management
memory_manager = MemoryManager(app, {
'memory_threshold_mb': app.config.get('MEMORY_THRESHOLD_MB', 4096),