Skip to content

Refactor: extract repo feature computation into separate module#57

Open
maithilmishra wants to merge 2 commits intoosslab-pku:mainfrom
maithilmishra:maithil
Open

Refactor: extract repo feature computation into separate module#57
maithilmishra wants to merge 2 commits intoosslab-pku:mainfrom
maithilmishra:maithil

Conversation

@maithilmishra
Copy link
Copy Markdown

What I did

Extracted pure repository feature computation logic from update.py into a dedicated module.

The following calculations were moved:

  • match_issue_references() – extracts referenced issue numbers from text
  • compute_issue_close_time_median() – computes median issue close time
  • detect_issue_resolutions() – determines which commits or PRs resolved issues

Why

Previously, update.py mixed GitHub API calls, database operations, and pure computation logic.
This made the code harder to test, reason about, and reuse.

By separating the pure feature computation:

  • Logic is now independently testable
  • update.py is easier to read and maintain
  • No behavior or data model changes were introduced

Changes

  • Added gfibot/data/features/repo_features.py containing the extracted functions
  • Updated gfibot/data/update.py to call the new functions
  • Reduced complexity:
    • _update_repo_stats() from 27 → 18 lines
    • _locate_resolved_issues() from 105 → 55 lines
  • Added unit tests in tests/data/test_repo_features.py
    • ~30 test cases covering edge cases and expected behavior

Safety

  • Pure refactor only — no functional or schema changes
  • All API calls, DB reads/writes, and logging remain in update.py
  • Feature outputs are unchanged

How to test

pytest tests/data/test_repo_features.py -v

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.

1 participant