Skip to content

Commit

Permalink
Dev facade fixes (#2165)
Browse files Browse the repository at this point in the history
* facade fixes

Signed-off-by: Isaac Milarsky <[email protected]>

* session close

Signed-off-by: Isaac Milarsky <[email protected]>

---------

Signed-off-by: Isaac Milarsky <[email protected]>
Signed-off-by: Isaac Milarsky <[email protected]>
  • Loading branch information
IsaacMilarky authored Feb 3, 2023
1 parent 3d1dcc8 commit e5fe29a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
17 changes: 8 additions & 9 deletions augur/tasks/git/facade_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,9 @@ def nuke_affiliations_facade_task():
from augur.tasks.init.celery_app import engine

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():
Expand Down Expand Up @@ -515,7 +514,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")
Expand Down Expand Up @@ -567,17 +566,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}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
5 changes: 2 additions & 3 deletions augur/tasks/github/facade_github/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion augur/tasks/start_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,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()
)

Expand Down

0 comments on commit e5fe29a

Please sign in to comment.