U
    'e5
                     @   s8   d dl T d dlmZ edddd Zedkr4e  dS )	    )*)tqdmT)Zcommitc            	      C   sn  t d d} dddgdddgd	dd
gg}tjj|d}d}||  |k rjttjj|| | | | |  gddgdD ]}tjj|jdst d|  |  t|j	D ]}tjj|j|jdrqt d| d|  |j
jjpd}|j
jjpd}|| }|dk rd}|j|jjd|jj|j
jj|j
jjd|jd |j|jjddd|||d t  qt  qr|d7 }q:dS )uL  
    Для тестирования патча: ( cd /opt/eva-app; python3 -m patch.202310091518_fix_sprints )
    Здесь можно работать с моделями через models.CmfTask и т.д.
    Для прогрессбара используйте:
    for task in tqdm(models.CmfTask.list()):
        ...
    u#   Запуск патча fix_sprintsi  cache_status_typez==ZIN_PROGRESSZworkflowz!=NZlogic_prefixzlist.agile_sprint)filterr   zmembers.op_gantt_task.*z	members.*)r   sliceZfields)task_list_idu   Стартуем )r   Ztask_idu6   Отсутсвует история по задаче u    в спринте append   )Zestimate_spestimate_durationZestimate_workZestimate_countZstatus_typezscope-changed)Ztimetracker_history_idZtask_operateZtask_list_operater
   remaining_durationspent_duration)printZmodelsZCmfListcountr   listZCmfListHistoryOTRidZdo_startZmembersZop_gantt_taskZsched_durationvalueZactual_workZhistory_otr_addZagile_story_pointsZ
sched_workr   Zhistory_rte_addZcommit_all_ds)	stepZ_filterZcntiZsprintZtaskr
   r   r    r   ./opt/eva-app/patch/202310091518_fix_sprints.pyfix_sprints   sL    	.
  r   __main__N)Zpatch.includer   Zapp_contextr   __name__r   r   r   r   <module>   s
   
,