Do FindByPath in two queries
Do FindByPath in two queries

This starts the find_by_path check by initially doing a query by the
model id and only if that fails doing the more complex check for
route/redirect matches.

I'm doing this change to try resolve the issues where we frequently see
queries that take a couple of seconds to look up a content item or
publish intent. I was unable to establish conclusive evidence that this
improved things much but felt that it offered at least a simpler option.

For ContentItems I expect that most of these (90+%) will be found from
the initial base_path query and only a few found the other way. So in
most cases just a single query runs. However for PublishIntents I expect
that in most cases there won't be a PublishIntent so 2 queries will run.

My hope is that the additional latency incurred by an extra query will
be offset by the queries being faster and reduced data that needs to be
pulled in cases where there are multiple matches.

alphagov/content-store,alphagov/content-store