Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #102 from banderso-n/404searchfix
Browse files Browse the repository at this point in the history
Perform 404 searching at SQL level to improve performance
  • Loading branch information
granthughes authored Jul 2, 2016
2 parents 588c97d + 304006e commit 24cd1d3
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions Repositories/UrlTrackerRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public static List<UrlTrackerModel> GetUrlTrackerEntries(int? maximumRows, int?
public static List<UrlTrackerModel> GetNotFoundEntries(int? maximumRows, int? startRowIndex, string sortExpression = "", string keyword = "")
{
List<UrlTrackerModel> notFoundEntries = new List<UrlTrackerModel>();
List<UrlTrackerModel> urlTrackerEntries = GetUrlTrackerEntries(maximumRows, startRowIndex, sortExpression, true);
List<UrlTrackerModel> urlTrackerEntries = GetUrlTrackerEntries(maximumRows, startRowIndex, sortExpression, true, keyword: keyword);
foreach (var notFoundEntry in urlTrackerEntries.GroupBy(x => x.OldUrl).Select(x => new
{
Count = x.Count(),
Expand All @@ -332,19 +332,6 @@ public static List<UrlTrackerModel> GetNotFoundEntries(int? maximumRows, int? st
notFoundEntries.Add(notFoundEntry.UrlTrackerModel);
}

if (!string.IsNullOrEmpty(keyword))
{
IEnumerable<UrlTrackerModel> filteredNotFoundEntries = notFoundEntries;
if (!string.IsNullOrEmpty(keyword))
{
filteredNotFoundEntries = filteredNotFoundEntries.Where(x =>
(x.CalculatedOldUrl != null && x.CalculatedOldUrl.ToLower().Contains(keyword)) ||
(x.Referrer != null && x.Referrer.ToLower().Contains(keyword))
);
}
notFoundEntries = filteredNotFoundEntries.ToList();
}

if (!string.IsNullOrEmpty(sortExpression))
{
string sortBy = sortExpression;
Expand Down

0 comments on commit 24cd1d3

Please sign in to comment.