Generate the query up front, started looking into :ticketId during
querying.