Using SQLAlchemy and Postgres functions to produce JSON structures from joins | Hacker News Reader