
    Ʌi	                     R    d dl  d dlmZ  ed      d        Zedk(  r e        yy)    )*)tqdmT)commitc                  \   t        d       t        j                  j                         j                         j                  } t        t        j                  j                  |       j                         j                               }g dg dg}g d}d}d}	 t        j                  j                  |||||z   g      }|sy|D ]V  }|j                  r|j                  j                  |k(  r*|j                  }|}	d	}
d
}t        j                  j                         }|j                  |j                   |
z         }|rC|j"                  }	|j$                  }
|j&                  }|j                  |j                   |
z         }t        j)                  d|j*                  j,                   |||	|
||d      }|j/                  d       ||_        |j/                  d       t        j0                  j3                  dd|gd|j4                  j,                  i       Y t7                ||z   })u   
    Для тестирования патча: ( cd /opt/eva-app; python3 -m patch.202601291040_personal_calendars )
    45 cек / 1000 пользователей
    u*   Запуск патча personal_calendars)
user_local==T)namezNOT LIKEzPERF_%)zcalendar.timezonezcalendar.calc_num_yearszcalendar.calc_num_back_yearszcalendar.parentr   d   T)filterfieldsslice      )yearu   Календарь F)r	   parentparent_calendartimezonecalc_num_yearscalc_num_back_years
calc_untildirty)	only_datapersonr   calendar_id)r   valuesN)printdatetimenow
astimezonetzinfoint	utcoffsettotal_secondsmodels	CmfPersonlistcalendarr   datetodayreplacer   r   r   r   CmfCalendarcodevaluesaveCmfTaskResAssignbulk_updateid
cmf_commit)tzserver_timezone_filter_fieldsisteppersonsr   r   r   r   r   r)   r   new_calendars                  5/opt/eva-app/patch/202601291040_personal_calendars.pypersonal_calendarsr<      s    

67						 	+	+	-	4	4B(++//3==?MMOPO)+IJGqG	AD
""''wwqRSVZRZm'\ !	@F6??#9#9V#C$ooO&HN"#MM'')EEJJ,GHJ*33!0!?!?&5&I&I#"]]

^0K]L
!--*6;;+<+<*=> /!-$7% . 	L -*FOKK$K'##//$7OYfhthwhwh}h}X~/C!	@F 	HS     __main__N)patch.includer   app_contextr<   __name__ r=   r;   <module>rC      s:      D8 8t z r=   