feat: add stats page

This commit is contained in:
Krispire Admin
2026-05-31 14:54:15 +05:30
parent d3ad443fde
commit 72f4e6527c
14 changed files with 750 additions and 36 deletions
+16 -3
View File
@@ -180,8 +180,12 @@ func (s *PostService) ListByHandle(ctx context.Context, handle, viewerID string,
return posts, total, nil
}
// ListMine is the owner's view of their own posts. Reshare hydration
// is skipped — the caller can't reshare their own posts.
// ListMine is the owner's view of their own profile feed — authored
// posts plus reshares (the repo's ListByUser unions the two). The
// viewer here is by construction the feed owner, so every reshared
// row is one the viewer themselves reshared — we flip
// ViewerHasReshared inline rather than spending a hydration round-trip
// to learn what we already know.
func (s *PostService) ListMine(ctx context.Context, userID string, limit, offset int) ([]model.Post, int, error) {
if limit <= 0 || limit > 50 {
limit = 20
@@ -189,7 +193,16 @@ func (s *PostService) ListMine(ctx context.Context, userID string, limit, offset
if offset < 0 {
offset = 0
}
return s.posts.ListByUser(ctx, userID, limit, offset)
posts, total, err := s.posts.ListByUser(ctx, userID, limit, offset)
if err != nil {
return nil, 0, err
}
for i := range posts {
if posts[i].ResharedAt != nil {
posts[i].ViewerHasReshared = true
}
}
return posts, total, nil
}
// ImagePresign returns a one-shot R2 PUT URL for a post image.