-- TEST QUERY - Run this after applying the fix to see if it worked

-- Should show actual project names with file counts and time
SELECT 
    COALESCE(project_name, 'No Project') as project,
    COUNT(*) as activities,
    COUNT(DISTINCT 
        CASE 
            WHEN window_title LIKE '%.%' THEN 
                SUBSTRING_INDEX(window_title, ' - ', 1)
            ELSE window_title 
        END
    ) as files,
    CONCAT(
        FLOOR(SUM(duration)/1000/3600), 'h ',
        FLOOR((SUM(duration)/1000%3600)/60), 'm'
    ) as total_time
FROM activity_records
WHERE developer_id = 'ankita_gholap'
AND DATE(timestamp) = CURDATE()  -- Use CURRENT_DATE for PostgreSQL
AND application_name IN ('Cursor.exe', 'Code.exe')
GROUP BY project_name
ORDER BY SUM(duration) DESC;

-- Expected output should be like:
-- project          | activities | files | total_time
-- -----------------|------------|-------|------------
-- timesheet        | 45         | 25    | 2h 30m
-- some_project     | 20         | 10    | 1h 15m
-- another_project  | 15         | 8     | 45m

-- If you still see mostly "general" or NULL, the fix didn't work properly
