Refactor: extract repo feature computation into separate module#57
Open
maithilmishra wants to merge 2 commits intoosslab-pku:mainfrom
Open
Refactor: extract repo feature computation into separate module#57maithilmishra wants to merge 2 commits intoosslab-pku:mainfrom
maithilmishra wants to merge 2 commits intoosslab-pku:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did
Extracted pure repository feature computation logic from
update.pyinto a dedicated module.The following calculations were moved:
match_issue_references()– extracts referenced issue numbers from textcompute_issue_close_time_median()– computes median issue close timedetect_issue_resolutions()– determines which commits or PRs resolved issuesWhy
Previously,
update.pymixed 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:
update.pyis easier to read and maintainChanges
gfibot/data/features/repo_features.pycontaining the extracted functionsgfibot/data/update.pyto call the new functions_update_repo_stats()from 27 → 18 lines_locate_resolved_issues()from 105 → 55 linestests/data/test_repo_features.pySafety
update.pyHow to test