Skip to content

Commit

Permalink
Added methods for feature Prs_not_reviwed_Merged in PUllrequestAnalys…
Browse files Browse the repository at this point in the history
…isService

Signed-off-by: RISHIKESHk07 <[email protected]>
  • Loading branch information
RISHIKESHk07 committed Aug 1, 2024
1 parent ffc623d commit d6bbf30
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions backend/analytics_server/mhq/api/pull_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,13 @@ def get_team_lead_time_trends(
week.isoformat(): adapt_lead_time_metrics(average_lead_time_metrics)
for week, average_lead_time_metrics in weekly_lead_time_metrics_avg_map.items()
}

@app.route("/teams/<team_id>/prs/merged_not_reviwed", methods={"GET"})
def merge_not_reviwed(team_id : str):
query_validator = get_query_validator()
team: Team = query_validator.team_validator(team_id)
pr_analytics = get_pr_analytics_service()
result = pr_analytics.get_prs_not_reviewed_merged(team.id)
return result
# return {'message':'hellothere'}

3 changes: 3 additions & 0 deletions backend/analytics_server/mhq/service/code/pr_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ def __init__(self, code_repo_service: CodeRepoService):

def get_prs_by_ids(self, pr_ids: List[str]) -> List[PullRequest]:
return self.code_repo_service.get_prs_by_ids(pr_ids)

def get_prs_not_reviewed_merged(self,team_id):
return self.code_repo_service.get_prs_not_reviewed_merged(team_id)

def get_team_repos(self, team_id: str) -> List[OrgRepo]:
return self.code_repo_service.get_team_repos(team_id)
Expand Down
19 changes: 19 additions & 0 deletions backend/analytics_server/mhq/store/repos/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,25 @@ def get_team_repos(self, team_id) -> List[OrgRepo]:

team_repo_ids = [tr.org_repo_id for tr in team_repos]
return self.get_repos_by_ids(team_repo_ids)

@rollback_on_exc
def get_prs_not_reviewed_merged(self,team_id):
AllOrg = self.get_team_repos(team_id)
AllOrg_ids = [tr.id for tr in AllOrg]
print(AllOrg)
AllPullRequestEventReviweinOrgIds = (self._db.session.query(PullRequestEvent)
.filter(PullRequestEvent.org_repo_id.in_(AllOrg_ids))
.all()
)
ListofReviwedPrs = [ tr.pull_request_id for tr in AllPullRequestEventReviweinOrgIds]
AllPullRequestMergedNotReviwed = (self._db.session.query(PullRequest)
.filter(PullRequest.id.not_in(ListofReviwedPrs))
.filter(PullRequest.state == PullRequestState.MERGED)
.all())
print(AllPullRequestMergedNotReviwed)

return {"countofMergedReviewedPrs": len(AllPullRequestEventReviweinOrgIds),"countOfMergedNOtReviwedPrs":len(AllPullRequestMergedNotReviwed)}


@rollback_on_exc
def get_team_repos_by_team_id(self, team_id: str) -> List[TeamRepos]:
Expand Down

0 comments on commit d6bbf30

Please sign in to comment.