Skip to content

Story 2452: User Profile Integration – Contribution Bio - #2533

Open
julhoang wants to merge 2 commits into
julia/implement-user-rolesfrom
julia/contribution-bio-content
Open

Story 2452: User Profile Integration – Contribution Bio#2533
julhoang wants to merge 2 commits into
julia/implement-user-rolesfrom
julia/contribution-bio-content

Conversation

@julhoang

@julhoang julhoang commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Issue: #2452

⚠️ Stacked PR — based on julia/implement-user-roles, not develop. ⚠️

Summary & Context

Populates the bio card on the user profile page with each user's real library contributions instead of the hardcoded demo dict. Contributions are grouped by role (Author, Maintainer, Contributor), sourced from the same role data that backs the Edit User profile role dropdown.

Changes

Wire real contribution data to the bio card

  • Add User.get_contributor_data() — returns library contributions grouped by role label ({role: [library, …]}), in precedence order Author → Maintainer → Contributor, with each role's libraries ordered by commit count. Reuses the existing get_role_library_options() source of truth rather than adding new queries.
  • Omit any role the user holds in no library; return an empty dict when the user has no contributions at all, which the bio card already treats as "hide the whole contribution section."
  • Set contributor_data from the real query on CurrentUserProfileView

Cache the computed data

  • Cache each user's contribution data in Redis (CONTRIBUTOR_DATA_CACHE_TIMEOUT, default 24h), keyed per user. An empty dict is cached as a real value, distinct from a miss.
  • Invalidate in recompute_displayed_profile_roles (via delete_pattern), the task already run after every author/maintainer/commit import and on the daily beat — so the cache clears whenever the underlying data actually changes. The TTL is only a backstop for a missed invalidation.

Risks & Considerations

  • Freshness relies on the import workflow, not manual edits. Author/Maintainer/Contributor data only changes through the Celery import (which ends in recompute_displayed_profile_roles → cache clear), so no signal-based invalidation is wired. The one uncovered path is a direct edit of authors/maintainers on the LibraryVersion admin form; that would show stale data until the next import or the 24h TTL. Acceptable because that admin edit isn't part of the real workflow. If it ever becomes one, we can add an m2m_changed signal on the through models.
  • Why 24h TTL: the explicit invalidation is the real freshness mechanism; the TTL only fires if that invalidation is missed (e.g. an import task that errors before clearing). Sized to the daily recompute cadence — long enough for a high cache hit rate, short enough to cap worst-case staleness at a day.

Peer-Testing Guidelines

  1. Log in as a user who authors/maintains/has commits in at least one library
  2. Visit http://localhost:8000/users/me/ – the bio card's contribution section should list each role with its libraries, ordered Author → Maintainer → Contributor.
  3. Confirm a role you don't hold (e.g. Author) is not shown at all, rather than shown empty.
  4. Log in as another user with no library contributions and visit http://localhost:8000/users/me/ again — the entire contribution section should be hidden.

Screenshots

Sample user with contributions Empty State with No Contributions
Screenshot 2026-07-20 at 6 34 53 PM Screenshot 2026-07-20 at 6 37 23 PM

Self-review Checklist

  • Tag at least one team member from each team to review this PR
  • Link this PR to the related GitHub Project ticket

Frontend

  • UI implementation matches Figma design
  • Tested in light and dark mode
  • Responsive / mobile verified
  • Accessibility checked (keyboard navigation, etc.)
  • Ensure design tokens are used for colors, spacing, typography, etc. – No hardcoded values
  • Test without JavaScript (if applicable)
  • No console errors or warnings

Summary by CodeRabbit

  • New Features

    • Profile contributor information is now generated from each user’s actual roles and contributions.
    • Contributor libraries are grouped by role and ordered by contribution activity.
    • Contributor information is cached for faster profile loading.
  • Bug Fixes

    • Cached contributor information is refreshed automatically after profile role recalculation, preventing stale results.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cf1de37b-a386-4cc6-a236-37f4b25cd152

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately reflects the main change: user profile contribution bio data.
Description check ✅ Passed The description includes the required issue, summary, changes, risks, screenshots, and checklist sections, with the needed links.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch julia/contribution-bio-content

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@julhoang julhoang changed the title Julia/contribution bio content Story 2452: User Profile Integration – Contribution Bio Jul 21, 2026
@julhoang julhoang linked an issue Jul 21, 2026 that may be closed by this pull request

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@users/models.py`:
- Line 660: Update the data population logic at the display_name_short reference
to invoke the library method and append its returned name rather than the bound
method object.

In `@users/tasks.py`:
- Line 207: Guard the cache invalidation in users/tasks.py at the
contributor-data cache cleanup with hasattr(cache, "delete_pattern"), using a
safe fallback such as cache.clear() when unavailable; also update
users/tests/test_profile_role.py lines 33-35 with the same guard so local-memory
cache backends work. For production, avoid blocking Redis KEYS behavior by using
versioning or configuring django-redis for SCAN/ITERMAP.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 63c5daf2-fbd9-4d49-9d4a-0acfadb4f882

📥 Commits

Reviewing files that changed from the base of the PR and between ee1852b and 46a9d39.

📒 Files selected for processing (5)
  • config/settings.py
  • users/models.py
  • users/tasks.py
  • users/tests/test_profile_role.py
  • users/views.py

Comment thread users/models.py
Comment thread users/tasks.py
@julhoang
julhoang force-pushed the julia/contribution-bio-content branch from 46a9d39 to 554fd57 Compare July 21, 2026 23:02
@ycanales

Copy link
Copy Markdown
Collaborator

Works great @julhoang !

From my testing, where I also tried the cache clear after recompute_displayed_profile_roles:
image
image

Looks good even if you're a mega contributor like @herzog0 😅
image

@julhoang
julhoang force-pushed the julia/implement-user-roles branch from f2a5177 to 4df420f Compare July 23, 2026 00:32
@herzog0
herzog0 self-requested a review July 23, 2026 18:00
Comment thread config/celery.py
@julhoang
julhoang force-pushed the julia/contribution-bio-content branch from 554fd57 to fb6ed64 Compare July 23, 2026 19:10

@herzog0 herzog0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All working just fine, thanks!

Image

@julhoang
julhoang force-pushed the julia/implement-user-roles branch from 4df420f to 88aa0b4 Compare July 28, 2026 22:28
@julhoang
julhoang force-pushed the julia/contribution-bio-content branch from fb6ed64 to bbf2571 Compare July 28, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webpage Integration: User Profile - Contribution Bio

3 participants