Skip to content

Commit b5bd6be

Browse files
committed
more stuff for stats
1 parent defc312 commit b5bd6be

File tree

4 files changed

+51
-5
lines changed

4 files changed

+51
-5
lines changed

VinePlus.Web/Pages/Models.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ public static ThreadView create(Parsers.Thread thread) {
116116

117117
public record ProfilePostView(string username, int no_posts);
118118

119+
public record BoardView(string board, int no_posts);
120+
119121
public record ImageData(
120122
[property: JsonPropertyName("dateCreated")]
121123
string date_created,

VinePlus.Web/Pages/Queries.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,20 @@ public static IEnumerable<ProfilePostView> getPostViews(ComicvineContext context
324324
.Select(x => new ProfilePostView(x.Key, x.Count()));
325325
}
326326

327+
public static IEnumerable<BoardView> getBoardsViews(ComicvineContext context) {
328+
return context
329+
.Threads
330+
.GroupBy(thread => thread.Board.Text)
331+
.OrderByDescending(group => group.Count())
332+
.Take(10)
333+
.Select(x => new BoardView(x.Key, x.Count()));
334+
}
335+
336+
public static int getTotalPosts(ComicvineContext context) {
337+
return context.Posts.Count();
338+
}
339+
340+
public static int getTotalThreads(ComicvineContext context) {
341+
return context.Threads.Count();
342+
}
327343
}

VinePlus.Web/Pages/Stats/Index.cshtml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,28 @@
4141
</span>
4242
}
4343
</div>
44-
<div class="mini-heading">number of threads for each board</div>
45-
<div class="mini-heading">total number of posts</div>
46-
<div class="mini-heading">total number of threads</div>
47-
<div class="mini-heading">link to user stats</div>
44+
<div class="mini-heading">Boards summary</div>
45+
<div class="user-container" >
46+
<span class="thread-odd thread-item thread-header thread-item-title">Board</span>
47+
<span class="thread-odd thread-item thread-header thread-item-posts"># Posts</span>
48+
@foreach (var (index, item) in Model.board_summary.Select((t, i) => (i,t))) {
49+
<span class="@Url.Content($"{Helpers.getThreadRow(index)} thread-item thread-item-title")">
50+
<a>
51+
@item.board
52+
</a>
53+
</span>
54+
<span class="@Url.Content($"{Helpers.getThreadRow(index)} thread-item thread-item-posts")">
55+
@item.no_posts
56+
</span>
57+
}
58+
</div>
59+
60+
<div class="mini-heading">More stats</div>
61+
<div class="user-container" >
62+
<span class="thread-odd thread-item thread-header thread-item-title">Statistic</span>
63+
<span class="thread-odd thread-item thread-header thread-item-posts">Value</span>
64+
<span class="thread-item thread-item-title">Number of Posts</span>
65+
<span class="thread-item thread-item-posts">@Model.total_posts</span>
66+
<span class="thread-odd thread-item thread-item-title">Number of Threads</span>
67+
<span class="thread-odd thread-item thread-item-posts">@Model.total_threads</span>
68+
</div>

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@ public class Index(ComicvineContext context) : PageModel
77
{
88
public IEnumerable<ThreadView> top_threads;
99
public IEnumerable<ProfilePostView> top_users;
10+
public IEnumerable<BoardView> board_summary;
11+
public int total_threads;
12+
public int total_posts;
13+
1014
public void OnGet() {
1115
top_threads = Queries.getArchivedThreads(context, 1, SortForumBy.NoPosts).Take(10);
12-
top_users = Queries.getPostViews(context);
16+
top_users = [];//Queries.getPostViews(context);
17+
total_posts = Queries.getTotalPosts(context);
18+
total_threads = Queries.getTotalThreads(context);
19+
board_summary = Queries.getBoardsViews(context);
1320
}
1421
}

0 commit comments

Comments
 (0)