Refactor code for completeness metric detail view

The template code to generate the table for the completeness metric
detail view was over complicated, hard to maintain and hard to read.
I have refactored the code by using more suitable variable names as
well as a useful helper method.

Signed-off-by: Konrad Reiche <konrad.reiche@gmail.com>