(PDB-658) Moving events querying to the new query engine

This commit moves over the existing event and node querying features into the
query engine. This required extending the query engine to support
>,>=,<,<= on dates, fact subqueries and some additional validation on subqueries.

This does NOT include moving over event distinct-resources? to the new query
engine. Queries against the node's certname must now use "certname" as
the field (as previously "name"). Docs change related to that will be
made separately.
(PDB-658) Moved event-counts endpoints to the query engine

aggregate event counts just delegates to event counts and event counts
delegates to events sql function. Switching that call to conditionally use
the query engine (for :v4 when distinct-resources? are false) moved it
over, no additinoal query engine functionality was needed.
Merge pull request #982 from senior/ticket/master/pdb-658-moving-events-to-qe

(PDB-658) Moving events querying to the new query engine