U
    ؠhb                  
   @   s  d dl mZmZ d dlZd dl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d eedZe Zered eD ] \ZZZede de d qed ed eD ],\ZZZeekrede de d qed ed ed  ed! ed" ed# ed$ ed% ed& ned' W 5 Q R X ed( ed) dS )*    )create_enginetextN)load_dotenvDATABASE_URLDB_HOSTZ	localhostDB_PORTZ5432DB_NAMEZtimesheet_dbDB_USERZpostgresDB_PASSWORD zpostgresql://:@/z'=== Quick Fix for Case Sensitivity ===
z21. Finding all case variations of developer IDs...a  
        SELECT DISTINCT 
            CAST(developer_id AS VARCHAR) as original_id,
            LOWER(CAST(developer_id AS VARCHAR)) as lower_id,
            COUNT(*) as records
        FROM activity_records
        WHERE LOWER(CAST(developer_id AS VARCHAR)) IN ('riddhidhakhara', 'ankita gholap', 'ankita_gholap')
        GROUP BY developer_id
        ORDER BY lower_id, original_id
    z   Found these variations:z   - 'z' (z	 records)z;
2. Option 1: Standardize all developer IDs to lowercase...z   This would update:z' -> ''z
   Run this SQL to fix:z   UPDATE activity_recordsz)   SET developer_id = LOWER(developer_id)z-   WHERE developer_id != LOWER(developer_id);z@
3. Option 2: Update your API to handle case-insensitive queriesz    Change your API queries from:z   WHERE developer_id = :dev_idz
   To:z>   WHERE LOWER(CAST(developer_id AS VARCHAR)) = LOWER(:dev_id)z)   No records found for these developers!z!
4. RECOMMENDED FIX FOR YOUR API:a  
In your activity data API endpoint, update the query to be case-insensitive:

Example for Python/SQLAlchemy:
    query = '''
        SELECT * FROM activity_records
        WHERE LOWER(CAST(developer_id AS VARCHAR)) = LOWER(:dev_id)
        AND DATE(timestamp) BETWEEN :start_date AND :end_date
    '''
    
Example for raw SQL:
    WHERE LOWER(developer_id::varchar) = LOWER($1)
    
This will match 'riddhidhakhara' with 'RiddhiDhakhara' or any other case variation.
)Z
sqlalchemyr   r   osZdotenvr   getenvr   r   r   r   r	   r
   ZengineprintZconnectZconnZexecuteresultZfetchallZ
variationsZoriglowercount r   r   ./quick_fix_case_sensitivity.py<module>   sL   
"


