Skip to content
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

Adds ability to sync personal repos #336

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,17 @@ def get_org_repos(self, org_repos: List[OrgRepo]) -> List[OrgRepo]:
self._api.get_repo(org_repo.org_name, org_repo.name)
for org_repo in org_repos
]

repo_idempotency_key_org_repo_map = {
org_repo.idempotency_key: org_repo for org_repo in org_repos
}

return [
self._process_github_repo(org_repos, github_repo)
self._process_github_repo(
repo_idempotency_key_org_repo_map.get(str(github_repo.id)), github_repo
)
for github_repo in github_repos
if repo_idempotency_key_org_repo_map.get(str(github_repo.id))
]

def get_repo_pull_requests_data(
Expand Down Expand Up @@ -190,19 +198,15 @@ def get_revert_prs_mapping(
return self.github_revert_pr_sync_handler(prs)

def _process_github_repo(
self, org_repos: List[OrgRepo], github_repo: GithubRepository
self, org_repo: OrgRepo, github_repo: GithubRepository
) -> OrgRepo:

repo_idempotency_key_id_map = {
org_repo.idempotency_key: str(org_repo.id) for org_repo in org_repos
}

org_repo = OrgRepo(
id=repo_idempotency_key_id_map.get(str(github_repo.id), uuid.uuid4()),
id=org_repo.id,
org_id=self.org_id,
name=github_repo.name,
provider=self.provider,
org_name=github_repo.organization.login,
org_name=org_repo.org_name,
default_branch=github_repo.default_branch,
language=github_repo.language,
contributors=self._api.get_repo_contributors(github_repo),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def sync_org_repos(self, org_id: str):
def _sync_org_repos(self, org_id: str) -> List[OrgRepo]:
try:
org_repos = self.code_repo_service.get_active_org_repos(org_id)
self.etl_service.get_org_repos(org_repos)
org_repos = self.etl_service.get_org_repos(org_repos)
self.code_repo_service.update_org_repos(org_repos)
return org_repos
except Exception as e:
Expand Down
Loading