import logging


logger = logging.getLogger(__name__)


class UserService:

    @staticmethod
    def get_user_name(user):
        """Helper method to safely get advisor name"""
        if not user:
            return "Unknown"
        try:
            if hasattr(user, 'profile') and user.profile:
                return user.profile.full_name
            else:
                return user.username or user.email
        except Exception as exc:
            logger.warning(
                f"Failed to get name for user {user.id}: {str(exc)}"
            )
            return user.username or user.email
