Skip to content

Commit 777c89d

Browse files
committed
Added possibility to filter for ranges
1 parent c493cbf commit 777c89d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

LinkDotNet.Blog.Web/Shared/Admin/Dashboard/DateRangeSelector.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
{ "Since Today", DateTime.UtcNow.Date },
2323
};
2424

25-
private void RaiseDateTimeSpanChanged(ChangeEventArgs args)
25+
private async Task RaiseDateTimeSpanChanged(ChangeEventArgs args)
2626
{
27-
Console.WriteLine(args.Value);
27+
await DateTimeSpanChanged.InvokeAsync(DateTime.Parse(args.Value!.ToString()));
2828
}
2929

3030
}

LinkDotNet.Blog.Web/Shared/Admin/Dashboard/VisitCountPerPage.razor

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<div class="card-header">Blog Post Visit Counts</div>
1010
<div class="card-body">
1111
<div class="row">
12-
<DateRangeSelector></DateRangeSelector>
12+
<DateRangeSelector DateTimeSpanChanged="RefreshVisitCount"></DateRangeSelector>
1313
<table class="table table-striped table-hover">
1414
<tbody>
1515
<tr>
@@ -51,9 +51,9 @@
5151
private async Task LoadBlogPostInformationAsync()
5252
{
5353
visitData = await (from ur in blogDbContext.UserRecords
54-
join bp in blogDbContext.BlogPosts.Where(b => b.UpdatedDate > startDate)
54+
where ur.DateTimeUtcClicked > startDate
55+
join bp in blogDbContext.BlogPosts
5556
on ur.UrlClicked.Replace("blogPost/", string.Empty) equals bp.Id
56-
where bp.UpdatedDate > startDate
5757
group new { ur, bp } by new { ur.UrlClicked }
5858
into gp
5959
orderby gp.Count() descending
@@ -65,4 +65,10 @@
6565
ClickCount = gp.Count()
6666
}).ToListAsync();
6767
}
68+
69+
private async Task RefreshVisitCount(DateTime newBeginning)
70+
{
71+
startDate = newBeginning;
72+
await LoadBlogPostInformationAsync();
73+
}
6874
}

0 commit comments

Comments
 (0)