Fix get_duration db api method

This commit fixes the db api method for getting the duration for a
test_run. Originally this was just lazily copy and pasted from
subunit-trace into the db_api without much thought. However now that
there is a desire to use it, the method is refactored to actually work.

Change-Id: Ib88a4774b1f0b23f57709aef9b7d34c457a4efdb
Merge "Fix get_duration db api method"