Skip to content

Contributor Reputation Snapshot Builder#805

Open
ObedChibunna wants to merge 3 commits into
Pulsefy:mainfrom
ObedChibunna:feat/data-processing
Open

Contributor Reputation Snapshot Builder#805
ObedChibunna wants to merge 3 commits into
Pulsefy:mainfrom
ObedChibunna:feat/data-processing

Conversation

@ObedChibunna

Copy link
Copy Markdown

Summary

Describe what changed and why.

Linked Issue

Closes #744

Type of Change

  • feat
  • fix
  • docs
  • refactor
  • test
  • chore

Validation

  • Lint passed for affected area(s)
  • Tests passed for affected area(s)
  • Manual verification completed (if applicable)

Documentation

  • Documentation updated (or N/A with explanation)
  • Screenshots/videos attached for UI changes

Checklist

  • Branch name uses feat/, fix/, or docs/
  • Commit messages follow Conventional Commits
  • PR scope matches linked issue acceptance criteria

@drips-wave

drips-wave Bot commented May 29, 2026

Copy link
Copy Markdown

@ObedChibunna Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Cedarich

Copy link
Copy Markdown
Contributor

Please fix failing pytest

@Cedarich

Cedarich commented May 30, 2026

Copy link
Copy Markdown
Contributor

Test Failures Analysis & Solutions

Thanks for this contribution! The job is failing with 18 test failures across contributor reputation snapshot logic. Here's what needs to be fixed:

Critical Issues

1. Activity Streak Calculation (3 failing tests)
The streak calculation has an off-by-one error in _calculate_activity_streak() at line 354. The comparison current_date - activity_date == timedelta(days=streak + 1) doesn't work correctly for date comparisons.

Fix: Use .days to compare the difference:

def _calculate_activity_streak(self, timestamps: List[datetime], snapshot_date: datetime) -> int:
    if not timestamps:
        return 0
    
    unique_dates = sorted(set(ts.date() for ts in timestamps), reverse=True)
    if not unique_dates:
        return 0
    
    streak = 0
    current_date = snapshot_date.date()
    
    for activity_date in unique_dates:
        days_diff = (current_date - activity_date).days
        if days_diff == 0 or days_diff == 1:  # Today or yesterday
            streak += 1
            current_date = activity_date
        else:
            break
    
    return streak

2. Mock Data Generation (1 failing test)
The test expects ≥20 unique contributors, but only 2 unique addresses are generated because of this line:

address = f"G{('A' if i % 2 == 0 else 'B')}{'X' * 54}"  # Only 2 addresses!

Fix: Generate truly random unique addresses:

import random
hex_chars = ''.join(random.choices('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', k=54))
address = f"G{hex_chars}"

3. Integration Tests - 503 Service Unavailable (9 failing tests)
All API integration tests are failing because the database session isn't properly mocked. The error shows: '>=' not supported between instances of 'MagicMock' and 'datetime.datetime'

Fix: Ensure proper test fixtures and mocks in tests/integration/test_contributor_api.py:

  • Mock the PostgresService.SessionLocal() before making API calls
  • Set up proper return values for database queries that return datetime objects

4. Missing Module References (2 failing tests)
Tests that patch src.analytics.contributor_reputation modules need proper mock attributes.

Fix: Verify mocked objects have all required attributes with proper return values before use.

Recommended Action

Please update the code with the fixes above and rerun the tests. Feel free to ping me if you need clarification on any of the fixes!

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.

Data-processing: Contributor Reputation Snapshot Builder (From Contributor Registry)

3 participants