Skip to content

Commit

Permalink
Sync central issue details downwards when creating brand new local is…
Browse files Browse the repository at this point in the history
…sues

Summary:
When a new local issue is added and it corresponds to an existing central issue, we want to sync down those triage details so the local issue matches.

This diff does not change anything about how SAPP handles existing local issues: if an issue already exists, it is not modified and all downwards syncing happens from WWW.

If this diff causes issues, it can be disabled using https://www.internalfb.com/intern/justknobs/?name=sapp%2Fsapp#sync_local_issues_to_existing_central_issues

See [Central Issues Cutover Plan](https://docs.google.com/document/d/1Bx1zeiGDc_ygrp7tPNo21X3QTUFjNplhj7VmA5etGjc)

Reviewed By: yuhshin-oss

Differential Revision: D61165240

fbshipit-source-id: fff505312e78ceab9ecc41f7570c0477dea68b09
  • Loading branch information
alexblanck authored and facebook-github-bot committed Aug 14, 2024
1 parent d875958 commit 9beac7b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions sapp/pipeline/database_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,12 @@ def _save(self) -> RunSummary:
run_id = self.summary["run"].id.resolved()
log.info("Created run: %d", run_id)

# Get full list of issues before bulk_saver prunes them during _prepare
issues = self.bulk_saver.get_items_to_add(Issue)
self._save_central_issues_and_sync_local_issues(
self.summary["run"], self.bulk_saver.get_items_to_add(Issue)
)

self.bulk_saver.save_all(self.database)

self._save_central_issues(self.summary["run"], issues)

# Now that the run is finished, fetch it from the DB again and set its
# status to FINISHED.
with self.database.make_session() as session:
Expand Down Expand Up @@ -172,7 +171,10 @@ def _get_dry_run_summary(self) -> RunSummary:
),
)

def _save_central_issues(self, run: TRun, issues: List[Issue]) -> None:
"""Subclasses may implement this to save issue data to a second location before
the run status is changed to FINISHED"""
def _save_central_issues_and_sync_local_issues(
self, run: TRun, local_issues: List[Issue]
) -> None:
"""Subclasses may implement this to save issue data to a second location before the issues
saved and the run status is changed to FINISHED. They can also modify details
of yet-to-be-created local issues to match existing central issues."""
pass

0 comments on commit 9beac7b

Please sign in to comment.