
    ti              
       V   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Zd Zd	 Ze
j                  j                  e
      Z edej$                   dej&                  dej(                   dej*                           edej,                   dej.                           ed ee               e j0                         Z ee      Z ede         ed e j0                         ez
  j7                         d       ej9                           ed ee              y)    )datetime)ReportSections)update_account_sections)
ReportType)compute_dates_for_key)Accountz$78aac6a8-e3fa-452f-bd4b-5fbed77a2ec8c                 >   | j                   xs i }| j                  j                  xs i }|j                  d      xs i }|j                  d      dk(  ry |j                  d      r|n|j                  d      xs i }t	        |j                  d      |      }|sy ||fS )NdatelabelCustomkey)configurationreportmetadatagetr   )sectiontarget_end_datesection_configreport_configsection_datedate_configcomputeds          */tmp/run_update_v2_sections_noom_us_med.pyexpected_dates_for_sectionr      s    **0bNNN++1rM!%%f-3L H,"."2"25"9,@Q@QRX@Y@_]_K$[__U%;_MH      c                    t         j                  j                  | dt        j                  j
                  t        j                  j
                  g      j                  d      }d}|D ]o  }t        || j                        }|s|\  }\  }}|j                  d      |j                  d      k7  s$|j                  d      |j                  d      k7  sk|dz  }q |S )	NF)accountreport__is_deletedreport__type__inr   r   
start_datez%Y-%m-%dend_date   )r   objectsfilterr   REGULARvalue	DASHBOARDselect_relatedr   last_synced_dater   strftime)r   sectionsoutdatedr   resultr   expected_startexpected_ends           r   count_outdated_sectionsr0      s    %%,, $,,22J4H4H4N4NO -  nX	  H+GW5M5MN6<33nlOOL)^-D-DZ-PPz*l.C.CJ.OOMH  Or   )idzaccount=z name=z	 version=z	 is_demo=zfirst_synced_date=z last_synced_date=zoutdated_before=)r   zresult=zelapsed_seconds=z.2fzoutdated_after=N)r   creative_module.modelsr   (creative_module.services.section_servicer   creative_module.typesr   creative_module.utilsr   organization_auth.modelsr   
ACCOUNT_IDr   r0   r#   r   r   printr1   ad_account_nameversionis_demofirst_synced_dater)   now
started_atr-   total_secondsrefresh_from_db r   r   <module>rB      s(    1 L , 7 , 4
! . //



, F7#:#:"=YwFWW`ahapap`qr s 74455GH`H`Gab c 09:; <X\\^
	 	1 x  ,(,,.:5DDFsKL M     /89: ;r   