Skip to content

Extend User Model with contributions_count Field #1192

@arkid15r

Description

@arkid15r

Describe the solution you'd like

Enhance the OWASP Nest GitHub App user model by adding a contributions_count field and populating it during the data sync process. This field will reflect the total contributions of a user and replace the existing statistics display on the user details page.

Tasks

  1. Model Update

    • Add contributions_count field to the User model.

    • Populate this field during the data sync process using the same logic as:

      def idx_contributions_count(self):
          """Return contributions count for indexing."""
          from apps.github.models.repository_contributor import RepositoryContributor
      
          return (
              RepositoryContributor.objects.by_humans()
              .filter(user=self)
              .aggregate(total_contributions=Sum("contributions_count"))["total_contributions"]
              or 0
          )
  2. Indexing Update

    • Modify the indexing mixin to use the pre-calculated contributions_count field instead of recalculating it dynamically.
  3. Frontend Update

    • Update the user details page to display contributions_count in the Statistics section.
    • Replace the current statistics related to issues/releases with this new field.

Acceptance Criteria

  • The contributions_count field is added to the User model and populated during sync.
  • The index mixin uses this field instead of recalculating contributions.
  • The user details page displays contributions_count in the Statistics section.
  • Tests added/updated for the new functionality

Additional Notes

  • Ensure proper migration is created for adding contributions_count.
  • Validate that sync updates contributions correctly.
  • Test the UI update to confirm proper rendering.

Are you going to work on implementing this?

  • Yes
  • No

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions