o
    4%i                     @   s   d dl mZ d dlZd dl mZ ddlmZ d dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ eed	d
 Zdd ZdS )    )receiverN   )order_confirmed)get_channel_layer)async_to_sync)Orders)Shopc           
   
   K   s   zS| d}| d}g }t| d tjj|d }|r9z|j }|D ]
}|	t
|j q(W n   Y tjjd|d }td|||d td	 W d S  tyn }	 ztd
|	  W Y d }	~	d S d }	~	ww )Norder_idstore_idz( confirmed and started via custom signal)uuid	Confirmed)order_statusstore_uuid__uuidnotification)r	   countuser_idszSignal Execution CompletedzSignal Calling Issue: )getlogginginfor   objectsfilterfirstunit_admin_userallappendstrr   r   r   send_db_update_notification	Exception)
senderkwargsr	   r
   r   shopshop_adminsiorder_counte r%   B/var/www/html/Testing_prj/Navya-Bakers/orders/signals/receivers.pyorder_notification   s*   


r'   c                 C   s"   t  }t|jdd|| d d S )Nnotificationssend_notification)typemessagemsg_type)r   r   
group_send)message_typemsgchannel_layerr%   r%   r&   r   (   s   r   )django.dispatchr   r   custom_signalsr   channels.layersr   asgiref.syncr   orders.modelsr   shops.modelsr   r'   r   r%   r%   r%   r&   <module>   s    
