U
    Sh                     @   sF  d dl mZmZ d dlZd dlmZ d dlmZmZ e  edZ	e	seddZ
edd	Zed
dZeddZeddZde de de
 de de 
Z	ee	Zed e |ZeedZed ed ed dZeD ]bZe\ZZZZZereendZerend ZdZeedde deddedded 	 qesded! n ed" ed# ed$ ed% ed& ed' e Zeed(d)eiZe  Z!e!r ed*e d+ e!D ]J\ZZZereendZerend Zed,e d-e d.ed/d0 qned1e d2 ed3 W 5 Q R X dS )4    )create_enginetextN)load_dotenv)datetimedateDATABASE_URLDB_HOSTZ	localhostDB_PORTZ5432DB_NAMEZtimesheet_dbDB_USERZpostgresDB_PASSWORD zpostgresql://:@/z=== Quick Dashboard Test ===
a  
        SELECT 
            CAST(developer_id AS VARCHAR) as dev_id,
            DATE(timestamp) as activity_date,
            COUNT(*) as records,
            SUM(duration) / 3600 as hours,
            COUNT(DISTINCT application_name) as apps
        FROM activity_records
        WHERE duration > 0
        AND application_name IS NOT NULL
        GROUP BY developer_id, DATE(timestamp)
        ORDER BY activity_date DESC, dev_id
        LIMIT 20
    zDeveloper Activity Summary:z:Developer ID         | Date       | Records | Hours | Appsz<------------------------------------------------------------FZUnknownTz<20z | 7z5.1f4zNo data found!u   
⚠️ KEY INSIGHT:zIThe dashboard is showing '0h worked' because it's looking at TODAY's datez,but your data is from the dates shown above.uM   
✅ SOLUTION: Select one of the dates above in your dashboard's date picker!z=
============================================================z%Checking today's data specifically...a  
        SELECT 
            CAST(developer_id AS VARCHAR) as dev_id,
            COUNT(*) as records,
            SUM(duration) / 3600 as hours
        FROM activity_records
        WHERE DATE(timestamp) = :today
        AND duration > 0
        GROUP BY developer_id
    todayz
Data for today (z):z  z: z
 records, z.1fz hoursu   
❌ No data for today ()z(This is why the dashboard shows 0 hours!)"Z
sqlalchemyr   r   osZdotenvr   r   r   getenvr   r   r	   r
   r   r   ZengineprintZconnectZconnZexecuteresultZ
data_foundrowZdev_idZact_dateZrecordsZhoursZappsstrZ
dev_id_strZ	hours_valr   ZfetchallZ
today_data r   r   ./quick_dashboard_test.py<module>   s^   
".

	$