o
    PfhU                     @  sf   d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
mZ e Zejdeddd
dZdS )    )annotations)defaultdict)	APIRouterRequest)HTMLResponse)	templatessbz/sync)response_classrequestr   c           	        s  t ddjdddd jpg }|s#td| g i i dS d	d
 |D }t dd	d| jp:g }t
dd }|D ]}||d  |d   d7  < qCt dd	d| jpdg }t
t}|D ]}|ddkr~||d   d7  < qktd| |t|t|dS )Ningest_batches*
started_atT)desc   zsync/index.html)r
   rowsevent_statspending_statsc                 S  s   g | ]}| d r|d  qS )batch_id)get).0b r   -/var/www/html/bot/app/web/pages/sync/index.py
<listcomp>   s    zsync_index.<locals>.<listcomp>gov_staff_eventszbatch_id,event_typer   c                   S  s   t tS )N)r   intr   r   r   r   <lambda>   s    zsync_index.<locals>.<lambda>
event_type   match_decisionszbatch_id,decisiondecisionPENDING)r   tableselectorderlimitexecutedatar   TemplateResponsein_r   r   r   dict)	r
   batches	batch_idsevr   edecr   dr   r   r   
sync_index	   s*   *""r1   N)r
   r   )
__future__r   collectionsr   fastapir   r   fastapi.responsesr   app.web.depsr   r   routerr   r1   r   r   r   r   <module>   s    