ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/ssa/modules/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/ssa/modules/__pycache__/storage.cpython-311.pyc

�

��f`����dZddlZddlmZddlmZmZmZmZddl	Z	ddl	m
Z
mZmZm
Z
mZmZddlmZmZeGd�d����Zd	eefd
�Zd�Zd	eeeeffd�ZdS)
zF
Represents storage where ssa data is collected, stored and extracted
�N)�	dataclass)�List�Iterator�Tuple�Dict)�func�cast�case�literal_column�distinct�text)�
session_scope�
RequestResultc�D�eZdZUeed<eeed<eed<eed<dS)�
DomainData�domain_name�domain_total_reqs�is_a_wordpress_domain�urls_numberN)�__name__�
__module__�__qualname__�str�__annotations__r�int�bool���J/opt/cloudlinux/venv/lib64/python3.11/site-packages/ssa/modules/storage.pyrrsF������������C�y� � � ����������rr�returnc#�zK�t|��5}|�tjt	jdtj��t	jtj��t	j	tj
��t	jttj
�������tjt	jdtj�����tjt	jdtj����}t!j|d����}|D]^\}}t%|��}d}dgdz}|D]*\}	}
}}}
||t'|
��<t||
��}�+t)||||���V��_	ddd��dS#1swxYwYdS)z7
    Iterates data from database domain-by-domain.
    �%Hc��|dS�Nrr��items r�<lambda>z#iter_domains_data.<locals>.<lambda>/s
��VZ�[\�V]�r)�keyr�)rrrrN)r�queryr�domainr�strftime�
created_at�Count�id�max�	wordpress�countr�path�group_by�order_by�	itertools�groupby�tuplerr)�engine�db�results_by_hour�results_by_hour_groupedr�group�domain_results_by_hourr�requests_number_by_hour�_�hour�requests_num�is_wordpress�urlss              r�iter_domains_datarEs�����
�v�	�	�!�"��(�(�� ��M�$�
� 8�9�9��J�}�'�(�(��H�]�,�-�-��J�x�
� 2�3�3�4�4�
�
��(�� ��M�$�
� 8�9�9�
�
��(�� ��M�$�
� 8�9�9�
�
�	�#,�"3�O�I]�I]�"^�"^�"^��"9�	�	��K��%*�5�\�\�"��K�()�c�B�h�#�=S�
5�
5�9��4��|�T�5A�'��D�	�	�2�!�+�t�4�4����'�"9�&2�'�	���
�
�
�
�	�#!�!�!�!�!�!�!�!�!�!�!�!����!�!�!�!�!�!s�FF0�0F4�7F4c
#�K�t|��5}d�|D��}|�tjt	jdtj��t	jttj	tj�����d��t	j
tj���d��t	jttjtj�����d�����tj|k���t%tj�|��j�ddi���j�����tjt	jdtj�����tjt	jdtj����}d	}d
gdzd
gdzd
gdz}	}}|D]q\}
}}}
}|r/||
kr)|t3||||	���fV�d
gdzd
gdzd
gdz}	}}||t5|��<|
|t5|��<||	t5|��<|
}�r|
t3|
|||	���fV�d	d	d	��d	S#1swxYwYd	S)
z6
    Iterates urls data from database url-by-url.
    c�:�g|]}|�dd����S)�:z\:)�replace)�.0r3s  r�
<listcomp>z"iter_urls_data.<locals>.<listcomp>Hs&��L�L�L�$�T�\�\�#�u�5�5�L�L�Lrr"�url_throttled_reqs�url_total_reqs�
url_slow_reqs�
literal_bindsT)�compile_kwargsNrr))r3rLrMrN)rr*rr3rr,r-�Sumr	�hitting_limits�
sqlalchemy�Integer�labelr.r/�is_slow_request�filterr+r
�in_�
expression�compile�stringr4r5�dictr)r9r�	all_pathsr:�all_paths_escaped�	urls_data�
previous_pathrLrMrNr3rA�url_throttled_req�
url_total_req�url_slow_reqs               r�iter_urls_datardCs����
�v�	�	�2
�"�L�L�)�L�L�L���H�H����M�$�
� 8�9�9��H�T��,�j�.@���
�
��u�)�*�*��J�� �
�
��e�$�%�%��H�T��-�z�/A�C�C�
�
��e�O�$�$�
�
��&�� �K�/�
�
�
�&���#�'�'�(9�:�:�E�M�M�^m�os�]t�M�u�u�|�}�}�
�
�
�(����
�d�M�4L� M� M�
�
�
�(����
�d�M�4L� M� M�
�
�%	�,�
�
�C�"�H�q�c�B�h���b��-:�N��KT�	!�	!�F�D�$�)�=�,��
1��$�!6�!6�#�T�&�'9�#1�"/�	&�&�&������C�"�H�q�c�B�h���b��5B�N�"�->��s�4�y�y�)�(5�N�3�t�9�9�%�'3�M�#�d�)�)�$� �M�M��D��1�)�'�	
�
�
�
�	
�	
�	
�[2
�2
�2
�2
�2
�2
�2
�2
�2
�2
�2
�2
����2
�2
�2
�2
�2
�2
s�JJ<�<K�Kc#�K�t|��5}|�tjtj���tj|k���tj��}tj	t|��d���}|D]\}}|d�|D��fV��	ddd��dS#1swxYwYdS)zA
    Get information about durations of requests url-by-url.
    c��|dSr$rr%s rr'z#get_url_durations.<locals>.<lambda>�s
��$�q�'�rc��g|]\}}|��Srr)rJr@�durations   rrKz%get_url_durations.<locals>.<listcomp>�s��:�:�:�[�Q���:�:�:rN)rr*rr3rhrWr+r5r6r7�list)r9rr:r_�durations_by_pathr(r=s       r�get_url_durationsrk|s)����
�v�	�	�
;�"��H�H����"�
�
��&�� �K�/�
�
�
�(���
�
�	�&�-���O�O�1�1�3�3��+�	;�	;�J�C���:�:�E�:�:�:�:�:�:�:�:�	;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;�
;����
;�
;�
;�
;�
;�
;s�B$C�C�C)�__doc__r6�dataclassesr�typingrrrrrSrr	r
rrr
�ssa.dbrrrrErdrrrkrrr�<module>rps>��������!�!�!�!�!�!�.�.�.�.�.�.�.�.�.�.�.�.�����G�G�G�G�G�G�G�G�G�G�G�G�G�G�G�G�/�/�/�/�/�/�/�/������������%��*�!5�%�%�%�%�N6
�6
�6
�r;�d�3��c�
�?�.C�;�;�;�;�;�;r

Zerion Mini Shell 1.0