Sindbad~EG File Manager

Current Path : /home/numerotech/scans.numerotech.com/scan_v1/core/model/__pycache__/
Upload File :
Current File : //home/numerotech/scans.numerotech.com/scan_v1/core/model/__pycache__/QueryModel.cpython-310.pyc

o

6d��@s~ddlmZddlmZmZmZddlmZmZmZm	Z	m
Z
ddlmZm
Z
ddlmZeejdddd	�ZGd
d�d�ZdS)
�)�session)�request�	Blueprint�jsonify)�
create_engine�select�MetaData�Table�text)�and_�or_)�app�DATABASE_URITi)�
pool_pre_ping�pool_recyclec@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
QueryModelc
Csfzt�|_td|jdtd�|_td|jdtd�|_WdSty2}zt|�WYd}~dSd}~ww)N�abs_session_queriesT)�autoload�
autoload_with�abs_sessions)r�metar	�enginerr�	Exception�print)�self�e�r�&D:\conference\core\model\QueryModel.py�__init__s��zQueryModel.__init__cCsdt��}tdt|�d|d|d�}|�|�}|��|r(dd�|D�nd}|r0|dSdS)Nz)select * from conference where  conf_id =z and conf_key ='z' and 'z' <= conf_end_time ;cS�g|]}t|��qSr��dict��.0�rrrr�
<listcomp>�z2QueryModel.getConf_open_closed.<locals>.<listcomp>r)r�connectr
�str�execute�close)r�conf_id�conf_key�
current_dt�conn�stmt�result�resultsrrr�getConf_open_closeds$
zQueryModel.getConf_open_closedcCsVt��}td|d�}|j|||d�}|��|r!dd�|D�nd}|r)|dSdS)Nzselect * from z? where conf_id =:conf_id and delegate_no =:delegate_no limit 1;)r+�delegate_nocSrrr r"rrrr%%r&z.QueryModel.checkDelegateNo.<locals>.<listcomp>r�rr'r
r)r*)rr+r3�del_table_namer.r/r1rrr�checkDelegateNo szQueryModel.checkDelegateNocCsBt��}|�|j��|�}|��|jdr|jd}|Sd}|S)Nr)rr'r)r�insertr*�inserted_primary_key)r�datar.r0Zpk_idrrr�insert_delegate_query+s�z QueryModel.insert_delegate_querycCsHt��}td�}|j||d�}|��|rdd�|D�nd}|r"|SdS)NzXSELECT distinct(display_dt),dt from abs_sessions where conf_id=:conf_id  order by dt asc)r+cSrrr r"rrrr%7r&z&QueryModel.getDays.<locals>.<listcomp>r4)rr+r.r/r1r0rrr�getDays2szQueryModel.getDayscC�Jt��}td�}|j|||d�}|��|rdd�|D�nd}|r#|SdS)NzuSELECT distinct(hall),hall_id,dt,display_dt from abs_sessions where conf_id=:conf_id and dt=:conf_date order by hall;)r+�	conf_datecSrrr r"rrrr%Br&z'QueryModel.getHalls.<locals>.<listcomp>r4)rr+r=r.r/r1r0rrr�getHalls=�zQueryModel.getHallscCsLt��}td�}|j||||d�}|��|rdd�|D�nd}|r$|SdS)Nz�SELECT * from abs_sessions where conf_id=:conf_id and  hall_id=:hall_id and dt=:conf_date  and abs_session_id is not null order by starts_by asc�r+�hall_idr=cSrrr r"rrrr%Mr&z-QueryModel.getSessionName.<locals>.<listcomp>r4)rr+rAr=r.r/r1r0rrr�getSessionNameHszQueryModel.getSessionNamecCs<t��}td�}|j|||d�}|��|��}|r|SdS)NzOselect * from abs_sessions where conf_id=:conf_id and asession_id=:asession_id;)r+�asession_id�rr'r
r)r*�fetchone)rr+rCr.r/r1rrr�get_sessionSszQueryModel.get_sessioncCsFt��}td|d�}|j||||d�}|��|��}|r!|SdS)Nz_select * from abs_sessions where conf_id =:conf_id and hall_id=:hall_id and dt=:conf_date and 'z!' between starts_by and ends_by ;r@rD)rr+r-rAr=r.r/r1rrr�getCurrentSession^szQueryModel.getCurrentSessioncCsVt��}td�}|j|||d�}|��|rdd�|D�nd}t|�|r)|dSdS)Nz�select * from  abs_session_queries  where asession_id=:asession_id and date(created_at)=:conf_date order by created_at desc limit 1;)rCr=cSrrr r"rrrr%nr&z)QueryModel.getQueries.<locals>.<listcomp>r)rr'r
r)r*r)rrCr=r.r/r1r0rrr�
getQueriesiszQueryModel.getQueriescCr<)Nzxselect * from abs_session_queries where asession_id=:asession_id and created_at >:last_sync_at order by created_at desc;)rC�last_sync_atcSrrr r"rrrr%zr&z-QueryModel.getAutoQueries.<locals>.<listcomp>r4)rrCrIr.r/r1r0rrr�getAutoQueriesur?zQueryModel.getAutoQueriesc	Cs�g}zTt��}|��}|�d|g�	dd�|jD�}g}	|��}|dur'n
tt||��}|�|�q|�t	|��|�
�durBn|jdurHnqW|��|SW|��|S|��w)N�usp_get_pre_nxt_query�cS�g|]}|d�qS�rr�r#�crrrr%�r&z4QueryModel.usp_get_pre_nxt_query.<locals>.<listcomp>�r�raw_connection�cursor�callproc�descriptionrEr!�zip�append�list�nextsetr*)	rrC�sets�
connectionrS�names�set_�row_raw�rowrrrrK�s8
�
��
�z QueryModel.usp_get_pre_nxt_querycCs�g}zWt��}|��}|�d||||g�	dd�|jD�}g}		|��}
|
dur*n
tt||
��}|	�|�q!|�t	|	��|�
�durEn|jdurKnqW|��|SW|��|S|��w)N�usp_get_session_queryrLcSrMrNrrOrrrr%�r&z4QueryModel.usp_get_session_query.<locals>.<listcomp>rQ)rr+rAr=r-rZr[rSr\r]r^r_rrrr`�s8
�
��
�z QueryModel.usp_get_session_queryN)�__name__�
__module__�__qualname__rr2r6r:r;r>rBrFrGrHrJrKr`rrrrr
s	 rN)�flaskrrrr�
sqlalchemyrrrr	r
Zsqlalchemy.sqlrr�corer
�configrrrrrr�<module>s

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists