o
    i                     @   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
 d dlmZ d dlZd dlZd dlZd dl	mZ ejejd	 eeZed
dgdZeddgdZeddefddZeddefddZdS )    )	APIRouterHTTPException)progress_module)StartCurriculumRequest)get_gemini_model)HTMLResponse)typesN)FileResponse)levelz/goalskill-sales/api/progressProgress)prefixtagsz/goalskill-sales/api/fileFilesz/chart-view/{session_id}
session_idc                    sx   t jt jt}t j|}t j|}t j|}t j|ddd}t j|r0t|S t	d|  ddiS )Nfront
componentszdashboard.htmlzDashboard file not found at: errorzDashboard file not found)
ospathdirnameabspath__file__joinexistsr	   loggerr   )r   current_file_dirapp_dirback_dirroot_dir	file_path r    =/home/air/goalskill_sales/back/app/routers/progress_router.pyget_chart_page   s   r"   z/chart-data/{session_id}c              
      sH   zt | }|W S  ty# } ztd|  tdddd}~ww )uE   
    DB에서 실제 데이터를 조회하여 JSON으로 반환
    zError fetching chart data: i  zInternal Server Error)status_codedetailN)r   get_real_chart_data	Exceptionr   r   r   )r   dataer    r    r!   get_chart_data_api.   s   
r)   )fastapir   r   
app.modelsr   app.schemas.progress_schemar   app.core.configr   fastapi.responsesr   google.genair   jsonr   loggingr	   basicConfigINFO	getLogger__name__r   routerfile_routergetstrr"   r)   r    r    r    r!   <module>   s0    
