Fix counting number of triggers

This change set includes following 2 changes:

* Fix incorrect number of bad triggers.
  The previous implementation of getNumberOfTriggers() wrongly counts number of hosts instead of triggers. To fix it this change uses arg.useDistinct instead of using "distinct" statement directly.
* Add a function to count total number of triggers. I'll use it to calculate number of pages at client side.