Skip to content

Commit defc312

Browse files
committed
added top user stats
1 parent b327f7a commit defc312

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

VinePlus.Web/Pages/Models.cs

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

117+
public record ProfilePostView(string username, int no_posts);
118+
117119
public record ImageData(
118120
[property: JsonPropertyName("dateCreated")]
119121
string date_created,

VinePlus.Web/Pages/Queries.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,13 @@ public static IEnumerable<PostSummary> searchUserPosts(ComicvineContext context,
315315
;
316316
}
317317

318+
public static IEnumerable<ProfilePostView> getPostViews(ComicvineContext context) {
319+
return context
320+
.Posts
321+
.GroupBy(post => post.Creator.Text)
322+
.OrderByDescending(group => group.Count())
323+
.Take(10)
324+
.Select(x => new ProfilePostView(x.Key, x.Count()));
325+
}
326+
318327
}

VinePlus.Web/Pages/Stats/Index.cshtml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
ViewData[Keys.Headings] = "General statistics";
99
ViewData[Keys.Highlight] = MainHighlight.Stats;
1010
}
11-
<div class="mini-heading">Top 10 threads by posts</div>
11+
<div class="mini-heading">Top threads</div>
1212
<div class="userpost-container" >
13-
<span class="thread-odd thread-item thread-header thread-item-title">Title</span>
13+
<span class="thread-odd thread-item thread-header thread-item-title">Thread</span>
1414
<span class="thread-odd thread-item thread-header thread-item-posts"># Posts</span>
15-
@foreach (var (index, threadPosted) in Model.top10_threads.Select((t, i) => (i,t))) {
15+
@foreach (var (index, threadPosted) in Model.top_threads.Select((t, i) => (i,t))) {
1616
<span class="@Url.Content($"{Helpers.getThreadRow(index)} thread-item thread-item-title")">
1717
<span class="thread-tooltip">
1818
@Html.Raw(threadPosted.thread_name)
@@ -26,7 +26,21 @@
2626
</span>
2727
}
2828
</div>
29-
<div class="mini-heading">Top 10 users by posts</div>
29+
<div class="mini-heading">Top users</div>
30+
<div class="user-container" >
31+
<span class="thread-odd thread-item thread-header thread-item-title">User</span>
32+
<span class="thread-odd thread-item thread-header thread-item-posts"># Posts</span>
33+
@foreach (var (index, threadPosted) in Model.top_users.Select((t, i) => (i,t))) {
34+
<span class="@Url.Content($"{Helpers.getThreadRow(index)} thread-item thread-item-title")">
35+
<a href="@Url.Content($"/profile/{threadPosted.username}")">
36+
@threadPosted.username
37+
</a>
38+
</span>
39+
<span class="@Url.Content($"{Helpers.getThreadRow(index)} thread-item thread-item-posts")">
40+
@threadPosted.no_posts
41+
</span>
42+
}
43+
</div>
3044
<div class="mini-heading">number of threads for each board</div>
3145
<div class="mini-heading">total number of posts</div>
3246
<div class="mini-heading">total number of threads</div>

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ namespace VinePlus.Web.Pages.Stats;
55

66
public class Index(ComicvineContext context) : PageModel
77
{
8-
public IEnumerable<ThreadView> top10_threads;
8+
public IEnumerable<ThreadView> top_threads;
9+
public IEnumerable<ProfilePostView> top_users;
910
public void OnGet() {
10-
top10_threads = Queries.getArchivedThreads(context, 1, SortForumBy.NoPosts).Take(10);
11+
top_threads = Queries.getArchivedThreads(context, 1, SortForumBy.NoPosts).Take(10);
12+
top_users = Queries.getPostViews(context);
1113
}
1214
}

VinePlus.Web/wwwroot/css/main.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ h1, h2, h3, h5 {
181181
.thread-header {
182182
font-weight: bold;
183183
border-top: 1px solid #d1d4d6;
184+
color: #6d6d6d;
184185
}
185186

186187

@@ -901,4 +902,18 @@ figure[data-size="small"] {
901902
font-weight: 600;
902903
color: #105e10;
903904
text-align: center;
905+
margin-bottom: 0.7rem;
906+
margin-top: 1rem;
904907
}
908+
909+
.user-container {
910+
min-height: 30rem;
911+
margin: auto calc(4*var(--side-width));
912+
display: grid;
913+
grid-template-columns: 1fr auto;
914+
align-content: start;
915+
}
916+
.user-container > span:not(div:last-child) {
917+
border-right: 1px solid #d1d4d6;
918+
}
919+

0 commit comments

Comments
 (0)