-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added methods for feature Prs_not_reviwed_Merged in PulllrequestAnalysis Service #495
base: main
Are you sure you want to change the base?
Added methods for feature Prs_not_reviwed_Merged in PulllrequestAnalysis Service #495
Conversation
will clean up the the print statements and add types as well on the next commit |
Hey @RISHIKESHk07, have you had a chance to look at this? |
Evening @jayantbh , i did look at it , have done the changes except for one doubt , did ping samad about it , the change involved the need of adding interval as argument in the function , any where I could refer similar implementation of using interval , it was used inorder to not call all the prs from the db . It should be in the changes requested above , Thanks for notifying |
Sounds good, @RISHIKESHk07 |
@RISHIKESHk07 there's a failing linter check. |
i did not run the linting command mostly , where could i find it ? |
d6bbf30
to
60165f9
Compare
@RISHIKESHk07 Try using black version 24.4.2 |
60165f9
to
9ba14e2
Compare
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm. But I'll let @samad-yar-khan or @adnanhashmi09 take a final look.
Schema( | ||
{ | ||
Required("from_time"): All(str, Coerce(datetime.fromisoformat)), | ||
Required("to_time"): All(str, Coerce(datetime.fromisoformat)), | ||
} | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RISHIKESHk07 we additionally have a PR filter that we use in query params which is missing here. PR filter helps us add more querying from branch, author etc at a api level by just adding handler for the query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samad-yar-khan do i need to include pr_filter in the pr_analytics_service ( for prs_merged_without_review ) as well ? , any more info i need to know about this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, PR filter is applied at repo, so you will have to pass it down funcs as argument
PullRequest.created_in_db_at.between( | ||
interval.from_time, interval.to_time | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kamlesh72 created_at_in_db is the timestamp at which the data was stored in our db, which is irrelevant for a user. If they wish to query data in a date range, they are likely searching PRs that were either created or updated in that interval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samad-yar-khan created_at & updated_at should fix this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RISHIKESHk07 there is one more logical bug in this query. Its fetching open PRs as well as merged PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samad-yar-khan I believe this is for @RISHIKESHk07
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samad-yar-khan querying state for merged should correct that , i did try testing on a team repo but i see only closed & merged state Prs ,but we do have a few open Prs , (selcted pr merge while creating team did i miss anything ??)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that should work but I dont see that in your PR.
pr_analytics = get_pr_analytics_service() | ||
result = pr_analytics.get_prs_merged_without_review(team.id, interval) | ||
prs_map = [pr.id for pr in result] | ||
return {"PrsWithoutReviewMerged": prs_map} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't name our property keys that go in API responses in that case either. @RISHIKESHk07
61ddad8
to
9422021
Compare
@samad-yar-khan @jayantbh please take a look at the changes , apologies for the stale period of the PR was occupied with a university matter |
PullRequest.created_in_db_at.between( | ||
interval.from_time, interval.to_time | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that should work but I dont see that in your PR.
|
||
def get_non_paginated_merged_without_review(prs: List[PullRequest]) -> List[Dict[str,any]]: | ||
return { | ||
"data": [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this func has to be deleted ? since you are now using get_non_paginated_pr_response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samad-yar-khan Was going to implement my own before finding the get_non_paginated_pr_response
, and if i use the _filter_prs_merged_in_interval
, i would not need to query for merge state explicitly again as it will be handled by this method
self._db.session.query(PullRequest) | ||
.filter(PullRequest.repo_id.in_(AllOrg_ids)) | ||
.filter(PullRequest.state == PullRequestState.MERGED) | ||
.filter(PullRequest.merge_time == None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.filter(PullRequest.merge_time == None) | |
.filter(PullRequest.merge_time.is_(None)) |
or_( | ||
PullRequest.created_at.between( | ||
interval.from_time, interval.to_time | ||
), | ||
PullRequest.updated_at.between( | ||
interval.from_time, interval.to_time | ||
), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we are fetching PRs merged without review in interval. I think it would be valuable to look into _filter_prs_merged_in_interval
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samad-yar-khan will replace it with already implemented method , did see this while scrolling the file
AllOrg = self.get_team_repos(team_id) | ||
AllOrg_ids = [tr.id for tr in AllOrg] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AllOrg = self.get_team_repos(team_id) | |
AllOrg_ids = [tr.id for tr in AllOrg] | |
team_repos = self.get_team_repos(team_id) | |
repo_ids = [team_repo.id for team_repo in team_repos] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable names should be better and follow similar patterns as other part of the codebase. Having var names like AllOrg
and AllOrg_ids
makes the code harder to read and do not follow either snake case or camel case. We generally follow snake case in the python backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can move the repo fetching part to PullRequestAnalyticsService
and the just pass on repo_ids to the Repo. Separates the basic query from business layer and we can also follow the same pattern as get_prs_merged_in_interval
@RISHIKESHk07 no worries, can totally understand. There has been significant improvement in the code quality since the previous review. Its 90% there and almost usable 🚀 Keep pushing 💯 |
…isService Signed-off-by: RISHIKESHk07 <[email protected]>
…estAnalyticsService
9422021
to
ac14715
Compare
@samad-yar-khan please take a look if possible |
Linked Issue(s)
#207
Acceptance Criteria fulfillment
Proposed changes (including videos or screenshots)
Added required method in PullrequestAnalysisService & route in the pull_request.py