Skip to content

Commit

Permalink
update src id search to only match on relevant repos
Browse files Browse the repository at this point in the history
  • Loading branch information
ABrain7710 committed Oct 8, 2024
1 parent 08a92a1 commit 6940a26
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 12 additions & 2 deletions augur/application/db/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,25 @@ def get_repo_by_repo_id(repo_id):

return repo

def get_repo_by_src_id(src_id):
def get_github_repo_by_src_id(src_id):

with get_session() as session:

query = session.query(Repo).filter(Repo.repo_src_id == src_id)
query = session.query(Repo).filter(Repo.repo_src_id == src_id, Repo.repo_git.ilike(f'%https://github.com%'))
repo = execute_session_query(query, 'first')

return repo

def get_gitlab_repo_by_src_id(src_id):

with get_session() as session:

query = session.query(Repo).filter(Repo.repo_src_id == src_id, Repo.repo_git.ilike(f'%https://gitlab.com%'))
repo = execute_session_query(query, 'first')

return repo


def remove_working_commits_by_repo_id_and_hashes(repo_id, commit_hashes):

remove_working_commits = s.sql.text("""DELETE FROM working_commits
Expand Down
6 changes: 3 additions & 3 deletions augur/tasks/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from augur.tasks.init.celery_app import celery_app as celery
from augur.tasks.github.util.github_task_session import GithubTaskSession
from augur.tasks.github.util.github_graphql_data_access import GithubGraphQlDataAccess
from augur.application.db.lib import get_group_by_name, get_repo_by_repo_git, get_repo_by_src_id
from augur.application.db.lib import get_group_by_name, get_repo_by_repo_git, get_github_repo_by_src_id, get_gitlab_repo_by_src_id
from augur.tasks.github.util.util import get_owner_repo
from augur.application.db.models.augur_operations import retrieve_owner_repos, FRONTEND_REPO_GROUP_NAME, RepoGroup
from augur.tasks.github.util.github_paginator import hit_api
Expand Down Expand Up @@ -97,7 +97,7 @@ def add_gitlab_repos(user_id, group_name, repo_urls):

repo_src_id = result["id"]

repo = get_repo_by_src_id(repo_src_id)
repo = get_gitlab_repo_by_src_id(repo_src_id)
if repo:
# TODO: add logic to update the existing records repo_group_id if it isn't equal to the existing record
add_existing_repo_to_group(logger, session, group_id, repo.repo_id)
Expand Down Expand Up @@ -160,7 +160,7 @@ def add_new_github_repos(repo_data, group_id, session, logger):
repo_src_id = repo_data["databaseId"]
repo_type = repo_data["owner"]["__typename"]

repo = get_repo_by_src_id(repo_src_id)
repo = get_github_repo_by_src_id(repo_src_id)
if repo:
# TODO: add logic to update the existing records repo_group_id if it isn't equal to the existing record
add_existing_repo_to_group(logger, session, group_id, repo.repo_id)
Expand Down

0 comments on commit 6940a26

Please sign in to comment.