-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…1917) ## Summary Fixes #1747 ### Time to review: __10 mins__ ## Changes proposed Added transformation for the opportunity summary table which is a merger of 4 separate tables in the existing system (synopsis, synopsis history, forecast, forecast history) A little bit of cleanup / reorganization of the utility methods into their own file ## Context for reviewers The primary complexity here is that the join we need to do for each tables is a bit more complex than the prior tickets. In the Oracle tables, the primary key of the synopsis/forecast tables is just the opportunity ID, and the historical tables have it as opportunity ID + revision number. In order to uniquely identify a record between system, we need to join on 3 values: * `opportunity_id` - this narrows it down to the right opportuity * `is_forecast` - which effectively lets us know whether it connects to the forecast or synopsis tables * `revision_number` - which lets us determine whether it was a historical record or not (will be null in non-historical tables) With these 3 values, we have a key that lets us handle updates/deletes by properly linking records across the tables. --- Besides the fetching of data, the other primary implementation detail is the transformation itself. Since these tables largely overlap, I wrote one transformation method for all of them, and use some `isinstance` checks to handle the differences. MyPy does a good job of validating that I'm not making any mistakes on fields
- Loading branch information
Showing
10 changed files
with
1,125 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from typing import TypeAlias | ||
|
||
from src.db.models.staging.forecast import Tforecast, TforecastHist | ||
from src.db.models.staging.synopsis import Tsynopsis, TsynopsisHist | ||
|
||
SourceSummary: TypeAlias = Tforecast | Tsynopsis | TforecastHist | TsynopsisHist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.