webapp.py: fuse two sql queries in get_details