o
    eOj                     @   s~   d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZmZmZmZmZmZ e Zeddefdd	Zd
S )    )	APIRouterRequest)AsyncSession)render)AsyncSessionFactory)get_total_usersget_total_moviesget_total_viewsget_new_users_countget_active_users_countget_banned_users_countget_daily_registrationsget_top_moviesz
/dashboardrequestc                    s
  t  4 I d H T}t|I d H }t|I d H }t|I d H }t|ddI d H }t|ddI d H }t|ddI d H }t|I d H }t|ddI d H }	t|ddI d H }
W d   I d H  n1 I d H sbw   Y  dd |	D }d	d |	D }t	| d
||||||||||
dS )N   )days      
   )limitc                 S      g | ]}|d  qS )r    .0rr   r   D/var/www/www-root/data/www/ai-bot.pdev.uz/admin/routers/dashboard.py
<listcomp>!       zdashboard.<locals>.<listcomp>c                 S   r   )r   r   r   r   r   r   r   "   r   zdashboard/index.html)
total_userstotal_moviestotal_views	new_todaynew_week	active_7dbanned
reg_labelsreg_data
top_movies)
r   r   r   r	   r
   r   r   r   r   r   )r   sessionr   r   r    r!   r"   r#   r$   	reg_chartr'   r%   r&   r   r   r   	dashboard   s8   (r*   N)fastapir   r   sqlalchemy.ext.asyncior   admin.responsesr   bot.database.connectionr   bot.database.crud.analyticsr   r   r	   r
   r   r   r   r   routergetr*   r   r   r   r   <module>   s    (