
    soj                     r    d dl Z d dlT d dlmZ d dlmZ  G d de          Ze                                 dS )    N)*)	BaseModel)Userc                   X   e Zd ZdZ eeddd          Z edd          Z edd          Z	 e
            Z e
            Z edd          Z G d	 d
          Zeded          fd            Zeded          fd            Zedee         fd            Zededd fd            ZdS )Warlordz
    Warlord class
    warlordsCASCADE)backref	on_delete	on_updatec   T)
max_lengthnulli  c                       e Zd ZdZdS )Warlord.MetawarlordN)__name__
__module____qualname__db_table     /app/src/model/Warlord.pyMetar      s        r   r   returnc                      t                                                               t           j        t          j                                        k              S F
        Get active warlords
        :return: Active warlords
        )r   selectwhereend_datedatetimenowr   r   r   
get_activezWarlord.get_active   s9     ~~%%g&69J9N9N9P9P&PQQQr   c                  <   t                                                               t                                        t           j        t          j                                        k                                  t          j	        
                                          S r   )r   r   joinr   r    r!   r"   r#   order_bybountydescr   r   r   get_active_order_by_bountyz"Warlord.get_active_order_by_bounty!   s`     NNT$ZZU7#h&7&;&;&=&==>>Xdk&&(())		
r   c                  H    d t                                           D             S )r   c                 &    g | ]}|j         j        S r   )userid).0r   s     r   
<listcomp>z/Warlord.get_active_user_ids.<locals>.<listcomp>6   s    DDDGDDDr   )r   r$   r   r   r   get_active_user_idszWarlord.get_active_user_ids/   s%     EDw/A/A/C/CDDDDr   r-   c                 R   t                                                               t           j        | k    t           j        t
          j                                        k    z                                t           j                                                  	                                S )zr
        Get the latest active warlord by user
        :param user: The user
        :return: The warlord
        )
r   r   r    r-   r!   r"   r#   r'   r)   first)r-   s    r   get_latest_active_by_userz!Warlord.get_latest_active_by_user8   sk     NNUGLD(W-=@Q@U@U@W@W-WXYYXg&++--..UWW		
r   N)r   r   r   __doc__ForeignKeyFieldr   r-   	CharFieldepithetreasonDateTimeFieldr!   original_end_daterevoke_reasonr   staticmethodlistr$   r*   intr1   r4   r   r   r   r   r   	   sm         ?4yT]^^^Di2D111GY#D111F}H%I4888M        RY R R R \R 
Y 
 
 
 \
 Ec E E E \E 
 
 
 
 
 \
 
 
r   r   )r"   peeweesrc.model.BaseModelr   src.model.Userr   r   create_tabler   r   r   <module>rD      s         ) ) ) ) ) )      <
 <
 <
 <
 <
i <
 <
 <
~        r   