diff --git a/augur/tasks/git/facade_tasks.py b/augur/tasks/git/facade_tasks.py index d9daf4571b..e330be9dfc 100644 --- a/augur/tasks/git/facade_tasks.py +++ b/augur/tasks/git/facade_tasks.py @@ -324,10 +324,9 @@ def analyze_commits_in_parallel(repo_ids, multithreaded: bool)-> None: @celery.task def nuke_affiliations_facade_task(): logger = logging.getLogger(nuke_affiliations_facade_task.__name__) - # TODO: Is this session ever closed? - session = FacadeSession(logger) - - nuke_affiliations(session) + + with FacadeSession(logger) as session: + nuke_affiliations(session) @celery.task def fill_empty_affiliations_facade_task(): @@ -462,7 +461,7 @@ def generate_contributor_sequence(logger,repo_git_identifiers): -def generate_facade_chain(logger,repo_git_identifiers): +def generate_facade_chain(logger,repo_git_identifiers, firstRun=False): #raise NotImplemented logger.info("Generating facade sequence") @@ -514,17 +513,17 @@ def generate_facade_chain(logger,repo_git_identifiers): #Generate contributor analysis task group. facade_sequence.append(generate_contributor_sequence(logger,repo_git_identifiers)) - if nuke_stored_affiliations: + if nuke_stored_affiliations and firstRun: facade_sequence.append(nuke_affiliations_facade_task.si().on_error(facade_error_handler.s()))#nuke_affiliations(session.cfg) #session.logger.info(session.cfg) - if not limited_run or (limited_run and fix_affiliations): + if not limited_run or (limited_run and fix_affiliations) and firstRun: facade_sequence.append(fill_empty_affiliations_facade_task.si().on_error(facade_error_handler.s()))#fill_empty_affiliations(session) - if force_invalidate_caches: + if force_invalidate_caches and firstRun: facade_sequence.append(invalidate_caches_facade_task.si().on_error(facade_error_handler.s()))#invalidate_caches(session.cfg) - if not limited_run or (limited_run and rebuild_caches): + if not limited_run or (limited_run and rebuild_caches) and firstRun: facade_sequence.append(rebuild_unknown_affiliation_and_web_caches_facade_task.si().on_error(facade_error_handler.s()))#rebuild_unknown_affiliation_and_web_caches(session.cfg) logger.info(f"Facade sequence: {facade_sequence}") diff --git a/augur/tasks/git/util/facade_worker/facade_worker/facade07rebuildcache.py b/augur/tasks/git/util/facade_worker/facade_worker/facade07rebuildcache.py index 385de4dc36..252f82b0cd 100644 --- a/augur/tasks/git/util/facade_worker/facade_worker/facade07rebuildcache.py +++ b/augur/tasks/git/util/facade_worker/facade_worker/facade07rebuildcache.py @@ -43,7 +43,7 @@ # else: # import MySQLdb -def nuke_affiliations(session): +def nuke_affiliations(session, repo_id_list): # Delete all stored affiliations in the database. Normally when you # add/remove/change affiliation data via the web UI, any potentially affected @@ -56,7 +56,8 @@ def nuke_affiliations(session): session.log_activity('Info','Nuking affiliations') nuke = s.sql.text("""UPDATE commits SET cmt_author_affiliation = NULL, - cmt_committer_affiliation = NULL""") + cmt_committer_affiliation = NULL + WHERE repo_id IN :values""").bindparams(values=tuple(repo_id_list)) session.execute_sql(nuke) diff --git a/augur/tasks/github/facade_github/tasks.py b/augur/tasks/github/facade_github/tasks.py index 74c2aa139c..d15f4636dd 100644 --- a/augur/tasks/github/facade_github/tasks.py +++ b/augur/tasks/github/facade_github/tasks.py @@ -210,10 +210,9 @@ def link_commits_to_contributor(session,contributorQueue): query = s.sql.text(""" UPDATE commits SET cmt_ght_author_id=:cntrb_id - WHERE cmt_committer_email=:cntrb_email - OR cmt_author_raw_email=:cntrb_email + WHERE + cmt_author_raw_email=:cntrb_email OR cmt_author_email=:cntrb_email - OR cmt_committer_raw_email=:cntrb_email """).bindparams(cntrb_id=cntrb["cntrb_id"],cntrb_email=cntrb["email"]) #engine.execute(query, **data) diff --git a/augur/tasks/start_tasks.py b/augur/tasks/start_tasks.py index 2dae9d8f8c..6188c04dd9 100644 --- a/augur/tasks/start_tasks.py +++ b/augur/tasks/start_tasks.py @@ -97,7 +97,7 @@ def repo_collect_phase(): repo_task_group = group( *repo_info_tasks, chain(primary_repo_jobs,secondary_repo_jobs,process_contributors.si()), - chain(generate_facade_chain(logger,first_pass),create_grouped_task_load(dataList=first_pass,task=process_dependency_metrics)), + chain(generate_facade_chain(logger,first_pass,firstRun=True),create_grouped_task_load(dataList=first_pass,task=process_dependency_metrics)), collect_releases.si() )