feat: add get_top_authors and get_user_stars functions with profile star aggregation

Implement two new database functions: get_top_authors aggregates star counts across posts, projects, and gists tables with 60-second TTL caching, and get_user_stars computes total stars for a given user_uid. Refactor feed page to use get_top_authors instead of raw users table query, and display aggregated star count on profile pages via get_user_stars. Add Playwright integration test verifying profile star count increments after a post vote.
This commit is contained in:
2026-05-23 08:54:45 +00:00
parent 4d87532951
commit e30f94c5df
4 changed files with 60 additions and 4 deletions
+16
View File
@@ -49,6 +49,22 @@ def test_post_vote_increment(alice):
assert count == "1", f"expected vote count 1, got {count!r}"
def _profile_stars(page, username):
page.goto(f"{BASE_URL}/profile/{username}", wait_until="domcontentloaded")
value = page.locator(".profile-stat:has(.profile-stat-label:has-text('Stars')) .profile-stat-value").first
return int(value.text_content().strip())
def test_profile_stars_reflect_content_votes(alice):
page, user = alice
before = _profile_stars(page, user["username"])
create_post(page, "devlog", "Reputation contribution post")
page.locator(".post-action-btn.vote-up").first.click()
page.wait_for_url(f"{BASE_URL}/posts/*", wait_until="domcontentloaded")
after = _profile_stars(page, user["username"])
assert after == before + 1, f"expected stars {before + 1}, got {after}"
def test_post_comments_section(alice):
page, _ = alice
create_post(page, "rant", "Comment section test")