Extracted sql query for retrieving user apps to a function. Pass user ap...

...ps to profile template