-
Notifications
You must be signed in to change notification settings - Fork 119
handle deployment_type
updation of team_repos in update team repos api
#449
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
Conversation
idempotency_key_raw_org_repo_map = { | ||
str(repo.idempotency_key): repo for repo in repos | ||
} | ||
|
||
team_repos = get_repository_service().update_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.
Nit: Type hints
idempotency_key_raw_org_repo_map = { | ||
str(repo.idempotency_key): repo for repo in repos | ||
} | ||
|
||
team_repos = get_repository_service().update_team_repos( | ||
team, repos, idempotency_key_raw_org_repo_map | ||
) | ||
|
||
updated_repo_response: List[Dict[str, Any]] = [] | ||
for repo in team_repos: | ||
adapted_org_repo = adapt_org_repo(repo) | ||
raw_repo = idempotency_key_raw_org_repo_map.get(str(repo.idempotency_key)) | ||
if raw_repo: | ||
adapted_org_repo["deployment_type"] = raw_repo.deployment_type.value | ||
|
||
updated_repo_response.append(adapted_org_repo) |
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.
@adnanhashmi09 so you are returning the same data for deployment type that you are getting from the client ? What if the data changes during the API call ?
idempotency_key_raw_org_repo_map = { | ||
str(repo.idempotency_key): repo for repo in repos | ||
} | ||
|
||
team_repos = get_repository_service().update_team_repos( | ||
team, repos, idempotency_key_raw_org_repo_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.
if idempotency_key_raw_org_repo_map is generated from repos data, why are we even passing it down multiple levels of fucns down to the repo layer ? duplicate data being passed down funcs in diff format is not the best solution.
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.
makes sense
deployment_type=( | ||
TeamReposDeploymentType(repo.get("deployment_type")) | ||
if repo.get("deployment_type") | ||
else TeamReposDeploymentType.PR_MERGE | ||
), |
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.
What is RawOrgRepo data model? why does it have a TeamRepos property, deployment type
?
If it is a data model for TeamRepos then why doesn't it have team_id
and the name also tell that?
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.
Well, it only had org repo data and no team repos data. But it was only being used with team repos based api and services. It would be better to restructure this model. I will do that in the next commit
updated_repo_response: List[Dict[str, Any]] = [] | ||
for repo in team_repos: | ||
adapted_org_repo = adapt_org_repo(repo) | ||
raw_repo = idempotency_key_raw_org_repo_map.get(str(repo.idempotency_key)) | ||
if raw_repo: | ||
adapted_org_repo["deployment_type"] = raw_repo.deployment_type.value | ||
|
||
updated_repo_response.append(adapted_org_repo) |
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.
You should be able to find a better way for this given that the codebase can have a data model for TeamRepos with relevant fields
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.
yeah, it would be better to get TeamRepos and then map
def update_team_repos( | ||
self, | ||
team: Team, | ||
org_repos: List[OrgRepo], | ||
idempotency_key_raw_org_repo_map: Dict[str, RawOrgRepo] = {}, | ||
): |
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.
either pass data model for TeamRepos here or move this logic outside the repo layer. This is doing so much work that it is not responsible for
23c880d
to
51b574b
Compare
Purpose
This PR handles the updation of
deployment_type
field ofTeamRepos
. Frontend now sendsdeployment_type
field in the request body.Proposed changes (including videos or screenshots)
The
RawOrgRepo
dataclass has been extended to includedeployment_type
and the repo functions and service layer functions have been updated accordingly.