private async Task ActOnApplyFilterCallback(MetricsFilterDTO returnedFilterOptions)
 {
     filterOptions = returnedFilterOptions;
     await LoadMetrics();
 }
        public async Task <IActionResult> GetSystemMetrics([FromQuery] MetricsFilterDTO queryParameters)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(queryParameters.Timeframe))
                {
                    throw new ArgumentNullException("Timeframe");
                }

                var metrics = new Metrics();

                metrics.Timeframe = queryParameters.Timeframe;

                // Build base queryable
                var queryable = await BuildQueryableAsync(queryParameters.Timeframe);

                // If not metrics to return
                if (queryable == null || queryable.Count() == 0)
                {
                    return(NoContent());
                }

                // Pull reviewed/unreviewed metrics from querable
                var reviewed = MetadataProcessors.GetReviewed(queryable);

                metrics.Reviewed   = reviewed.ReviewedCount;
                metrics.Unreviewed = reviewed.UnreviewedCount;

                // Pull results metrics from queryable
                var results = MetadataProcessors.GetResults(queryable);

                metrics.ConfirmedDetection = results.ConfirmedCount;
                metrics.FalseDetection     = results.FalseCount;
                metrics.UnknownDetection   = results.UnknownCount;

                // Pull comments from queryable
                metrics.ConfirmedComments   = MetadataProcessors.GetComments(queryable, "yes");
                metrics.UnconfirmedComments = MetadataProcessors.GetComments(queryable, "no");
                metrics.UnconfirmedComments.AddRange(MetadataProcessors.GetComments(queryable, "don't know"));

                // Pull tags from queryable
                metrics.Tags = MetadataProcessors.GetTags(queryable);

                return(Ok(metrics));
            }
            catch (ArgumentNullException ex)
            {
                var details = new ProblemDetails()
                {
                    Detail = ex.Message
                };
                return(BadRequest(details));
            }
            catch (Exception ex)
            {
                var details = new ProblemDetails()
                {
                    Title  = ex.GetType().ToString(),
                    Detail = ex.Message
                };

                return(StatusCode(StatusCodes.Status500InternalServerError, details));
            }
        }