Fix database transaction scope for resources endpoint

Prior to this commit, the database transaction scope for
the `resources` endpoint did not encapsulate the `get-result-count`
call; this caused an error when handling requests that asked
for the count header.