|
|
|
@ -46,18 +46,19 @@ 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_connections = []
|
|
|
|
|
staff_connections = []
|
|
|
|
|
# for connection in sorted_connections:
|
|
|
|
|
# if hasattr(connection.user, 'customerprofile'):
|
|
|
|
|
# customer_connections.append(connection)
|
|
|
|
|
# elif hasattr(connection.user, 'staffprofile'):
|
|
|
|
|
# staff_connections.append(connection)
|
|
|
|
|
|
|
|
|
|
customer_connectionse = []
|
|
|
|
|
staff_connectionse = []
|
|
|
|
|
for connection in sorted_connections:
|
|
|
|
|
if hasattr(connection.user, 'customerprofile'):
|
|
|
|
|
customer_connectionse.append(connection)
|
|
|
|
|
elif hasattr(connection.user, 'staffprofile'):
|
|
|
|
|
staff_connectionse.append(connection)
|
|
|
|
|
|
|
|
|
|
print(staff_connectionse)
|
|
|
|
|
event = {
|
|
|
|
|
'type': 'online_user_connection_handler',
|
|
|
|
|
'staff_connections': staff_connections,
|
|
|
|
|
'customer_connections': customer_connections,
|
|
|
|
|
'staff_connections': staff_connectionse,
|
|
|
|
|
'customer_connections': customer_connectionse,
|
|
|
|
|
'online_users_ids': online_users_ids
|
|
|
|
|
}
|
|
|
|
|
async_to_sync(self.channel_layer.group_send)(
|
|
|
|
|