Move the bulk of path summary code to JS

This avoids the extra database queries to calculate completion
percentages.
Cosmetic