o
    f                     @   s   d 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	 ddl
mZ ddlmZ d	d
lmZ eejZeeeeZG dd dejZG dd dejZG dd dejZdS )zDatabase models.    N)states)GroupResultresult_from_tuple)settings)models)gettext_lazy   )managersc                   @   s  e Zd ZdZejeedddededdZ	ejddeded	d
Z
ejdeeddededd
ZejdededdZejdededdZejdejeededdZejdddededdZejdededdZejded ed!dZejddd"ed#ed$d%Zejded&ed'd(Zejded)ed*d+Zejdded,ed-d.Zejddd"ed/ed0d%Ze ZG d1d2 d2Zd3d4 Z d5d6 Z!dS )7
TaskResultzTask result/status.(DJANGO_CELERY_RESULTS_TASK_ID_MAX_LENGTH   TzTask IDz#Celery ID for the Task that was run
max_lengthuniqueverbose_name	help_textzPeriodic Task Namez'Name of the Periodic Task which was run)nullr   r   r   z	Task NamezName of the Task which was runzTask Positional ArgumentszBJSON representation of the positional arguments used with the task)r   r   r   zTask Named Argumentsz=JSON representation of the named arguments used with the task2   z
Task Statez#Current state of the task being run)r   defaultchoicesr   r   d   NWorkerzWorker that executes the task)r   r   r   r   r      Result Content TypeContent type of the result datar   r   r   @   Result Encoding.The encoding used to save the task result dataFResult DataUThe data returned by the task.  Use content_encoding and content_type fields to read.r   r   editabler   r   Created DateTimez6Datetime field when the task result was created in UTCauto_now_addr   r   Completed DateTimez1Datetime field when the task was completed in UTCauto_nowr   r   	Tracebackz/Text of the traceback if the task generated one)blankr   r   r   zTask Meta InformationzHJSON meta information about the task, such as information on child tasksc                   @   sp   e Zd ZdZdgZedZedZej	dgddej	dgd	dej	d
gddej	dgddej	dgddgZ
dS )zTaskResult.MetaTable information.
-date_doneztask resultztask results	task_namedjango_cele_task_na_08aec9_idxfieldsnamestatusdjango_cele_status_9b6201_idxworkerdjango_cele_worker_d54dd8_idxdate_createddjango_cele_date_cr_f04a50_idx	date_donedjango_cele_date_do_f59aad_idxN__name__
__module____qualname____doc__ordering_r   verbose_name_pluralr   Indexindexes rE   rE   O/var/www/html/venv/lib/python3.10/site-packages/django_celery_results/models.pyMeta^   s*    rG   c                 C   s.   | j | j| j| j| j| j| j| j| j| j	d
S )N
task_idr.   	task_argstask_kwargsr3   resultr9   	tracebackmetar5   rH   selfrE   rE   rF   as_dictt   s   zTaskResult.as_dictc                 C   s
   d | S )Nz <Task: {0.task_id} ({0.status})>)formatrO   rE   rE   rF   __str__   s   
zTaskResult.__str__)"r<   r=   r>   r?   r   	CharFieldgetattrr   rA   rI   periodic_task_namer.   	TextFieldrJ   rK   r   PENDINGTASK_STATE_CHOICESr3   r5   content_typecontent_encodingrL   DateTimeFieldr7   r9   rM   rN   r
   TaskResultManagerobjectsrG   rQ   rS   rE   rE   rE   rF   r      s    	r   c                   @   s\   e Zd ZdZejeedddededdZ	ej
edd	Zejed
d	ZdddZdS )ChordCounterzChord synchronisation.r   r   TGroup IDz$Celery ID for the Chord header groupr   zIJSON serialized list of task result tuples. use .group_result() to decode)r   zFStarts at len(chord header) and decrements after each task is finishedNc                    s&   t | j fddt| jD  dS )zReturn the :class:`celery.result.GroupResult` of self.

        Arguments:
            app (celery.app.base.Celery): app instance to create the
               :class:`celery.result.GroupResult` with.

        c                    s   g | ]}t | d qS )appr   ).0rra   rE   rF   
<listcomp>   s    z-ChordCounter.group_result.<locals>.<listcomp>ra   )CeleryGroupResultgroup_idjsonloads	sub_tasks)rP   rb   rE   ra   rF   group_result   s   

zChordCounter.group_result)N)r<   r=   r>   r?   r   rT   rU   r   rA   rg   rW   rj   PositiveIntegerFieldcountrk   rE   rE   rE   rF   r_      s.    	r_   c                   @   s   e Zd ZdZejeedddededdZ	ej
deded	d
Zej
dededdZejdededdZejdededdZejdddededdZdd Zdd Ze ZG dd dZdS ) r   zTask Group result/status.r   r   Tr`   z$Celery ID for the Group that was runr   r$   z7Datetime field when the group result was created in UTCr%   r'   z2Datetime field when the group was completed in UTCr(   r   r   r   r   r   r   r   NFr    r!   r"   c                 C   s   | j | j| jdS )Nrg   rL   r9   rn   rO   rE   rE   rF   rQ      s   zGroupResult.as_dictc                 C   s   d| j  dS )Nz<Group: >)rg   rO   rE   rE   rF   rS      s   zGroupResult.__str__c                   @   sF   e Zd ZdZdgZedZedZej	dgddej	dgd	dgZ
d
S )zGroupResult.Metar,   r-   zgroup resultzgroup resultsr7   django_cele_date_cr_bd6c1d_idxr0   r9   django_cele_date_do_caae0e_idxNr;   rE   rE   rE   rF   rG      s    rG   )r<   r=   r>   r?   r   rT   rU   r   rA   rg   r\   r7   r9   rZ   r[   rW   rL   rQ   rS   r
   GroupResultManagerr^   rG   rE   rE   rE   rF   r      sR    
r   )r?   rh   celeryr   celery.resultr   rf   r   django.confr   	django.dbr   django.utils.translationr   rA    r
   sorted
ALL_STATESziprY   Modelr   r_   rE   rE   rE   rF   <module>   s    
t)