SELECT
    -- *,
    EXTRACT(EPOCH FROM age(tr_end.created_at, tr_start.created_at)) as totalSec,
    tr_end.created_at - tr_start.created_at as duration
FROM test_runs tr_end
    JOIN test_runs tr_start 
        ON tr_start.run_id = tr_end.run_id 
        AND tr_start.test_name = tr_end.test_name
        AND tr_start.path = tr_end.path
        AND tr_start.run_type = 'start'
        AND tr_end.run_type = 'end';
    -- LEFT JOIN runs r on td.run_id = r.id

SELECT * from test_durations;