Exemple #1
0
        /// <summary>
        /// Build results object from aggregated data
        /// </summary>
        /// <returns>Aggregated results</returns>
        public IEnumerable <HistogramResultRow> GetResults()
        {
            if (_orderLearner.LearnedOrder.Count != 0)
            {
                TimeSpan lastAggregationBeginMark = TimeSpan.MinValue;

                if (AggregationTimePeriod != null)
                {
                    TimeSpan lastIterationBeginMark = _histogramItems.Max(h => h.Value.IterationBeginTime);

                    lastAggregationBeginMark = TimeSpan.FromTicks(
                        (lastIterationBeginMark.Ticks / AggregationTimePeriod.Value.Ticks)
                        * AggregationTimePeriod.Value.Ticks
                        );
                }

                ResultsMapper mapper = new ResultsMapper(_orderLearner);
                foreach (KeyValuePair <object, TestContextResultAggregate> histogramItem in _histogramItems)
                {
                    HistogramResultRow result = new HistogramResultRow(
                        histogramItem.Key,
                        histogramItem.Value,
                        mapper.Map(histogramItem.Value, true, histogramItem.Value.IterationBeginTime >= lastAggregationBeginMark ? null : AggregationTimePeriod).ToList()
                        );

                    yield return(result);
                }
            }
        }
        public IHttpActionResult Get([FromUri] SuggestionQuery query)
        {
            if (query == null)
            {
                throw new NullQueryStringException();
            }

            query.Validate();

            Coordinates sourceCoordinates = query.Coordinates();

            IEnumerable <GeoDataEntry> results = null;

            try
            {
                if (sourceCoordinates == null)
                {
                    results = DataProvider.Search(query?.Q, query.MaxResults);
                }
                else
                {
                    results = DataProvider.SearchNear(query?.Q,
                                                      new BoundingBox(sourceCoordinates, Defaults.defaultRadiusKm), query.MaxResults);
                }
            }
            catch (Exception ex)
            {
                AppLogger.Error("error querying hospitals", ex);
                throw new DataProviderException(ex);
            }

            return(Ok(ResultsMapper.Map(results, query, new LinkBuilder(this))));
        }
        /// <summary>
        /// Get Build results object from aggregated data
        /// </summary>
        /// <returns>Aggregated results</returns>
        public ResultsContainer GetResults()
        {
            ResultsContainer result = null;

            if (_orderLearner.LearnedOrder.Count != 0)
            {
                ResultsMapper mapper = new ResultsMapper(_orderLearner);
                IEnumerable <ResultItemRow> resultRows = mapper.Map(_statsAggregator);
                result = new ResultsContainer(resultRows.ToList(), new ResultItemTotals(_statsAggregator));
            }
            return(result);
        }