diff --git a/osinaweb/osinacore/__pycache__/consumers.cpython-310.pyc b/osinaweb/osinacore/__pycache__/consumers.cpython-310.pyc index 0f43f4c6..7f417cf3 100644 Binary files a/osinaweb/osinacore/__pycache__/consumers.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/consumers.cpython-310.pyc differ diff --git a/osinaweb/osinacore/consumers.py b/osinaweb/osinacore/consumers.py index 845b1f7a..0d9adbff 100644 --- a/osinaweb/osinacore/consumers.py +++ b/osinaweb/osinacore/consumers.py @@ -46,19 +46,24 @@ class OnlineUserConsumer(WebsocketConsumer): offline_connections = connections.filter(online=False, last_seen__isnull=False).order_by('-last_seen')[:5] sorted_connections = list(online_connections) + list(offline_connections) online_users_ids = [connection.user.id for connection in online_connections] - customer_connectionse = [] - staff_connectionse = [] + customer_connections = [] + staff_connections = [] for connection in sorted_connections: + connection_data = { + 'user_id': connection.user.id, + 'username': connection.user.username, + 'last_seen': connection.last_seen.isoformat() if connection.last_seen else None + } if hasattr(connection.user, 'customerprofile'): - customer_connectionse.append(connection) + customer_connections.append(connection_data) elif hasattr(connection.user, 'staffprofile'): - staff_connectionse.append(connection) + staff_connections.append(connection_data) - print(staff_connectionse) + print(staff_connections) event = { 'type': 'online_user_connection_handler', - 'staff_connections': staff_connectionse, - 'customer_connections': customer_connectionse, + 'staff_connections': staff_connections, + 'customer_connections': customer_connections, 'online_users_ids': online_users_ids } async_to_sync(self.channel_layer.group_send)(