예제 #1
0
        public ActionResult SearchResults(int id, DateTime?startDate, DateTime?endDate)
        {
            //List<Tweet> tweets;
            string tweets;
            IEnumerable <dynamic> fancyWordStats;

            startDate = startDate ?? DateTime.UtcNow.AddHours(-4);
            endDate   = endDate ?? DateTime.UtcNow;
            var profiler = MiniProfiler.Current; // it's ok if this is null

            //tweets = _tweetsRepository.GetTweetsInDateRange(id, (DateTime)startDate, DateTime.UtcNow);
            tweets = _tweetsRepository.GetTweetTextInDateRange(id, (DateTime)startDate, (DateTime)endDate);
            using (profiler.Step("3"))
            {
                //var temp = _tweetProcessor.WordCountStats(tweets.Select(st => st.Text).ToList());
                var temp = _tweetProcessor.WordCountStats(tweets);
                profiler.Step("4");
                var temp2 = temp.Where(i => i.Value > 2 && i.Key.Length > 2).OrderByDescending(f => f.Value);
                profiler.Step("5");
                fancyWordStats = temp2.Select(i => new { word = i.Key, total = i.Value, searchId = id });
                profiler.Step("6");
            }

            //var tweets = _tweetsRepository.GetTweetsInDateRange(id, (DateTime)startDate, (DateTime)endDate);
            //var fancyWordStats = _tweetProcessor.WordCountStats(tweets.Select(st => st.Text).ToList())
            //    .Where(i => i.Value > 2 && i.Key.Length > 2).OrderByDescending(f => f.Value)
            //    .Select(i => new { word = i.Key, total = i.Value, searchId = id });

            ViewBag.SearchId = id;

            return(View("SearchResults", fancyWordStats.ToList()));
        }
예제 #2
0
 public string GetTweetTextInDateRange(long searchId, DateTime startDate, DateTime endDate)
 {
     return(_tweetsRepository.GetTweetTextInDateRange(searchId, startDate, endDate));
 }