Skip to content

Commit b0c95e6

Browse files
committed
mostly done with stats stuff
1 parent 15886fb commit b0c95e6

File tree

5 files changed

+54
-3
lines changed

5 files changed

+54
-3
lines changed

VinePlus.Web/Pages/Queries.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,18 @@ public static int getTotalPosts(ComicvineContext context) {
332332
public static int getTotalThreads(ComicvineContext context) {
333333
return context.Threads.Count();
334334
}
335+
336+
public static int getUserThreadCount(ComicvineContext context, string user) {
337+
return context
338+
.Threads
339+
.Where(thread => thread.Creator.Text == user)
340+
.Count();
341+
}
342+
343+
public static int getUserPostCount(ComicvineContext context, string user) {
344+
return context
345+
.Posts
346+
.Where(post => post.Creator.Text == user)
347+
.Count();
348+
}
335349
}

VinePlus.Web/Pages/Stats/Index.cshtml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class Index(ComicvineContext context) : PageModel
1111
public IEnumerable<BoardView> board_summary;
1212
public int total_threads;
1313
public int total_posts;
14-
14+
1515
public void OnGet() {
1616
top_threads = Queries.getArchivedThreads(context, 1, SortForumBy.NoPosts).Take(10);
1717
total_posts = Queries.getTotalPosts(context);
@@ -20,6 +20,6 @@ public void OnGet() {
2020
}
2121

2222
public IActionResult OnPost(string searchQuery) {
23-
return Redirect($"/stats/posts/{searchQuery.Trim()}");
23+
return Redirect($"/stats/user?username={searchQuery.Trim()}");
2424
}
2525
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@page
2+
@using VinePlus.Web.Pages
3+
@model VinePlus.Web.Pages.Stats.User
4+
5+
@{
6+
Layout = "Shared/_Layout";
7+
ViewData[Keys.Title] = "User Statistics";
8+
ViewData[Keys.Headings] = "User statistics";
9+
ViewData[Keys.Highlight] = MainHighlight.Stats;
10+
}
11+
<div class="mini-heading">Statistics for @Model.user</div>
12+
<div class="user-container" >
13+
<span class="thread-odd thread-item thread-header thread-item-title">Statistic</span>
14+
<span class="thread-odd thread-item thread-header thread-item-posts">Value</span>
15+
<span class="thread-item thread-item-title">Number of Posts</span>
16+
<span class="thread-item thread-item-posts">@Model.post_count</span>
17+
<span class="thread-odd thread-item thread-item-title">Number of Threads</span>
18+
<span class="thread-odd thread-item thread-item-posts">@Model.thread_count</span>
19+
<span class="thread-item thread-item-title"><a href="/stats/posts/@Model.user">More stats for @Model.user</a></span>
20+
<span class="thread-item thread-item-posts"></span>
21+
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Microsoft.AspNetCore.Mvc.RazorPages;
2+
using VinePlus.Database;
3+
4+
namespace VinePlus.Web.Pages.Stats;
5+
6+
public class User(ComicvineContext context) : PageModel
7+
{
8+
public int post_count;
9+
public int thread_count;
10+
public string user;
11+
public void OnGet(string username) {
12+
user = username.Trim();
13+
thread_count = Queries.getUserThreadCount(context, user);
14+
post_count = Queries.getUserPostCount(context, user);
15+
}
16+
}

VinePlus.Web/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ The first can be time consuming - especially on low internet speed, while the ba
9393
- [x] add stats UI
9494
- [x] board stats
9595
- [x] viewing all threads a user has posted in, and number of posts
96-
- [ ] stats for number of posts, and threads a user has made
96+
- [x] stats for number of posts, and threads a user has made
9797

9898
### Api
9999
- [ ] better styling for api documentation

0 commit comments

Comments
 (0)