userportal: optimize GetAllFromVms query

Rewrote the stored function to optimize the query inside GetAllFromVms
Splitting out the boolean for simplicity
Joining instead of using exists on a complicated view
Removing distinct, as it's already inside the joined view

Change-Id: I541c9172c3ba9bcf989f9660baf06ec2e1fd02d7
Bug-Url: https://bugzilla.redhat.com/1151477
Signed-off-by: Tim Speetjens <tim.speetjens@redhat.com>