public ActionResult AggressiveIndex(string displayName, string tag)
{
using (DocumentSession.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(1)))
{
string header;
// 1. All the questions, ordered by most recent.
Lazy<IEnumerable<QuestionWithDisplayName>> questionsQuery = QuestionQuery(tag, out header).Lazily();
// 2. Popular Tags for a time period.
// StackOverflow calls it 'recent tags'.
Lazy<IEnumerable<RecentPopularTags.ReduceResult>> recentPopularTags = RecentPopularTagsQuery().Lazily();
// 3. Log in user information.
IQueryable<User> userQuery = UserQuery(displayName);
Lazy<IEnumerable<User>> lazyUserQuery = (userQuery != null ? userQuery.Lazily() : null);
var viewModel = new IndexViewModel(ClaimsUser)
{
Header = header,
QuestionListViewModel = new QuestionListViewModel
{
Questions = questionsQuery.Value.ToList()
},
RecentPopularTags =
recentPopularTags.Value.ToDictionary(x => x.Tag, x => x.Count),
UserFavoriteTagListViewModel = new UserTagListViewModel
{
Header = "Favorite Tags",
DivId1 = "interesting-tags",
DivId2 = "interestingtags",
Tags = lazyUserQuery == null
? null
: (lazyUserQuery.Value.
SingleOrDefault() ??
new User()).FavoriteTags
},
UserIgnoredTagList = new UserTagListViewModel
{
Header = "Ignored Tags",
DivId1 = "ignored-tags",
DivId2 = "ignoredtags",
Tags = null
}
};
return View("Index", viewModel);
}
}