Fix database query in profile api
Merge branch 'profile_db'