Add ability to filter out multiple events on the same resource

Because of Burgundy UI requirements, we need a way to issue
an event query that only returns a single (most recent) event for
any given resource that also satisfies all of the other constraints
specified in the query (including timestamp filtering).

Because of the timestamp filtering, we cannot rely on the
`latest-reports` table to optimize and simplify the query; if the
user specifies a query that is bounded by timestamps that are
earlier than the latest report, and also specifies the `latest-report`
flag, then no events would be returned.

This commit introduces a new query parameter for the `event-counts`
endpoint: 'distinct-resources'.  If this parameter is set to `true`,
then we use a more complicated SQL query that JOINS on a subselect
in order to filter out duplicate events on a given resource (besides
the event with the MAX timestamp in the result set).
Merge pull request #666 from cprice404/feature/burgundy/distinct-resources-in-event-queries

 Add ability to filter out multiple events on the same resource