
    Owg                     :    d dl mZmZmZ d dlmZ  G d de      Zy)    )BaseJobStoreConflictingIdErrorJobLookupError)datetime_to_utc_timestampc                   ^     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Z xZS )MemoryJobStorezh
    Stores jobs in an array in RAM. Provides no persistence support.

    Plugin alias: ``memory``
    c                 >    t         |           g | _        i | _        y N)super__init___jobs_jobs_index)self	__class__s    S/var/www/horilla/myenv/lib/python3.12/site-packages/apscheduler/jobstores/memory.pyr   zMemoryJobStore.__init__   s    
    c                 @    | j                   j                  |d      d   S )NNNr   )r   get)r   job_ids     r   
lookup_jobzMemoryJobStore.lookup_job   s     ##FL9!<<r   c                 ~    t        |      }g }| j                  D ]   \  }}|||kD  r |S |j                  |       " |S r
   )r   r   append)r   nownow_timestamppendingjob	timestamps         r   get_due_jobszMemoryJobStore.get_due_jobs   sT    1#6"jj 	 NC I$=  NN3	 
 r   c                 V    | j                   r| j                   d   d   j                  S d S Nr   )r   next_run_timer   s    r   get_next_run_timez MemoryJobStore.get_next_run_time   s&    15tzz!}Q--EEr   c                 F    | j                   D cg c]  }|d   	 c}S c c}w r!   )r   )r   js     r   get_all_jobszMemoryJobStore.get_all_jobs"   s    "jj)!)))s   c                 2   |j                   | j                  v rt        |j                         t        |j                        }| j                  ||j                         }| j                  j                  |||f       ||f| j                  |j                   <   y r
   )idr   r   r   r"   _get_job_indexr   insert)r   r   r   indexs       r   add_jobzMemoryJobStore.add_job%   s{    66T%%%$SVV,,-c.?.?@	##Isvv6

%#y!12$'#3 r   c                    | j                   j                  |j                  d      \  }}|t        |j                        | j	                  ||j                        }t        |j                        }||k(  r||f| j                  |<   nG| j                  |= | j	                  ||j                        }| j                  j                  |||f       ||f| j                   |j                  <   y Nr   )	r   r   r)   r   r*   r   r"   r   r+   )r   r   old_jobold_timestamp	old_indexnew_timestamp	new_indexs          r   
update_jobzMemoryJobStore.update_job.   s    !%!1!1!5!5cffl!K? (( ''wzzB	1#2C2CDM)%(-$8DJJy!

9%++M366BIJJi#})=>(+]';$r   c                     | j                   j                  |d      \  }}|t        |      | j                  ||      }| j                  |= | j                   |j
                  = y r/   )r   r   r   r*   r   r)   )r   r   r   r   r,   s        r   
remove_jobzMemoryJobStore.remove_job@   s^    ))--flCY; ((##Iv6JJuSVV$r   c                      g | _         i | _        y r
   )r   r   r#   s    r   remove_all_jobszMemoryJobStore.remove_all_jobsI   s    
r   c                 $    | j                          y r
   )r9   r#   s    r   shutdownzMemoryJobStore.shutdownM   s    r   c                 2   dt        | j                        }}|t        d      n|}||k  rk||z   dz  }| j                  |   \  }}|t        d      n|}||kD  r|}n4||k  r|dz   }n)|j                  |kD  r|}n|j                  |k  r|dz   }n|S ||k  rk|S )z
        Returns the index of the given job, or if it's not found, the index where the job should be
        inserted based on the given timestamp.

        :type timestamp: int
        :type job_id: str

        r   inf      )lenr   floatr)   )r   r   r   lohimidmid_jobmid_timestamps           r   r*   zMemoryJobStore._get_job_indexP   s     C

OB$-$5E%L9	2g7q.C%)ZZ_"G],9,AE%L}My(*1Wf$f$1W
 2g 	r   )__name__
__module____qualname____doc__r   r   r   r$   r'   r-   r5   r7   r9   r;   r*   __classcell__)r   s   @r   r   r      s@    =F*4<$%r   r   N)apscheduler.jobstores.baser   r   r   apscheduler.utilr   r    r   r   <module>rO      s    W W 6e\ er   