Optimize queries for open/merged changes by project + branch

When searching changes by project name and branch name the database
query only filters the changes by project. The filtering by branch is
only done afterwards in the code. If there is a big difference between
branches the search might become expensive since many roundtrips with
the database may be needed until the changes for the specified branch
are found (because the result of each database query is limited to the
number of entries that can be shown on the result screen).

Change-Id: I7d0aede1db4ff716049af24a8c2fb1af99278d34
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
6 files changed