示例#1
0
        public async Task <IActionResult> Trend(string id, bool allWords)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(BadRequest("Trend search term must have a value."));
            }

            var originalTerm = id;

            id = SearchTermHelper.MakeSafeWordSearch(id, allWords);

            var resultData = await trendService.GetTrendDataForTermAsync(id);

            resultData.Term = originalTerm;

            return(View(new TrendViewModel
            {
                Term = originalTerm,
                Data = JsonConvert.SerializeObject(resultData),
                To = resultData.End,
                From = resultData.Start,
                MaxCount = resultData.CountMax,
                AllWords = allWords
            }));
        }
示例#2
0
        public async Task <ActionResult> GetPlotAggregateData(string term, [FromQuery] bool allWords)
        {
            term = WebUtility.UrlDecode(term);

            var originalTerm = term;

            term = SearchTermHelper.MakeSafeWordSearch(term, allWords);

            var results = await trendService.GetTrendDataForTermAsync(term);

            return(Ok(new PlotAggregateDataViewModel
            {
                Counts = results.Counts,
                Term = originalTerm,
                AllWords = allWords,
                Scores = results.Scores
            }));
        }
示例#3
0
        public async Task <ActionResult> GetPlotAggregateData(string term, [FromQuery] bool allWords)
        {
            var originalTerm = term;

            if (allWords)
            {
                term = SearchTermHelper.MakeAllWordSearch(term);
            }

            var results = await trendService.GetTrendDataForTermAsync(term);

            return(Ok(new PlotAggregateDataViewModel
            {
                Counts = results.Counts,
                Term = originalTerm,
                AllWords = allWords
            }));
        }