protected virtual async Task <IHttpActionResult> GetCountAsync(ExceptionlessSystemFilter sf, TimeInfo ti, string filter = null, string aggregations = null)
        {
            var pr = await _validator.ValidateQueryAsync(filter);

            if (!pr.IsValid)
            {
                return(BadRequest(pr.Message));
            }

            var far = await _validator.ValidateAggregationsAsync(aggregations);

            if (!far.IsValid)
            {
                return(BadRequest(far.Message));
            }

            sf.UsesPremiumFeatures = pr.UsesPremiumFeatures || far.UsesPremiumFeatures;
            var query = new RepositoryQuery <TModel>()
                        .SystemFilter(ShouldApplySystemFilter(sf, filter) ? sf : null)
                        .DateRange(ti.Range.UtcStart, ti.Range.UtcEnd, ti.Field)
                        .Index(ti.Range.UtcStart, ti.Range.UtcEnd);

            CountResult result;

            try {
                result = await _repository.CountBySearchAsync(query, filter, aggregations);
            } catch (Exception ex) {
                _logger.Error().Exception(ex)
                .Message("An error has occurred. Please check your filter or aggregations.")
                .Property("Search Filter", new { SystemFilter = sf, UserFilter = filter, Time = ti, Aggregations = aggregations })
                .Tag("Search")
                .Identity(CurrentUser.EmailAddress)
                .Property("User", CurrentUser)
                .SetActionContext(ActionContext)
                .Write();

                return(BadRequest("An error has occurred. Please check your search filter."));
            }

            return(Ok(result));
        }