Optimize queries for org_name and category

When a search is performed for org_name and/or category, the initial query uses a joins, but when the JSON is created, those same tables that were joined were being "included" again via a slow query.

This commit adds logic to check for the presence of the org_name or category parameter, and removes the corresponding table from the "includes" statement.