-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🎉 Source Orb: enrich credits ledger entries with cost basis data, description, and update expiration date fields #11528
Merged
marcosmarxm
merged 11 commits into
airbytehq:master
from
orbcorp:anushree/source-orb-credit-modification
Apr 26, 2022
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e31b477
Add cost basis data to connector and remap block_expiry_date field
anushree-agrawal 967bb72
Update dockerfile and orb.md
anushree-agrawal 64213f9
Update orb.md and comments
anushree-agrawal 5cbc2a5
Add entry_status=committed as filter for getting CreditLedgerEntries
anushree-agrawal 44c83f9
Update version information
anushree-agrawal 558b853
Move entry_status filter to the correct endpoint
anushree-agrawal a30682f
PR feedback: rename field and add docstring for committed entries
anushree-agrawal 9bde1bd
Fix unit tests to include entry_status param
anushree-agrawal c8887df
Add a unit test to validate transform behavior
anushree-agrawal 1698709
Format using gradlew format
anushree-agrawal a45226c
Bump connector veresion in spec and definitions
anushree-agrawal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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 |
---|---|---|
|
@@ -235,11 +235,18 @@ def request_params(self, stream_state: Mapping[str, Any], stream_slice: Mapping[ | |
Request params are based on the specific slice (i.e. customer_id) we are requesting for, | ||
and so we need to pull out relevant slice state from the stream state. | ||
Ledger entries can either be `pending` or `committed`. | ||
We're filtering to only return `committed` ledger entries, which are entries that are older than the | ||
reporting grace period (12 hours) and are considered finalized. | ||
`pending` entries can change during the reporting grace period, so we don't want to export those entries. | ||
Note that the user of super() here implies that the state for a specific slice of this stream | ||
is of the same format as the stream_state of a regular incremental stream. | ||
""" | ||
current_customer_state = stream_state.get(stream_slice["customer_id"], {}) | ||
return super().request_params(current_customer_state, **kwargs) | ||
params = super().request_params(current_customer_state, **kwargs) | ||
params["entry_status"] = "committed" | ||
return params | ||
|
||
def path(self, stream_slice: Mapping[str, Any] = None, **kwargs): | ||
""" | ||
|
@@ -268,6 +275,13 @@ def transform_record(self, ledger_entry_record): | |
del ledger_entry_record["customer"] | ||
ledger_entry_record["customer_id"] = nested_customer_id | ||
|
||
# Un-nest credit_block -> expiry_date into block_expiry_date and per_unit_cost_basis | ||
nested_expiry_date = ledger_entry_record["credit_block"]["expiry_date"] | ||
nested_per_unit_cost_basis = ledger_entry_record["credit_block"]["per_unit_cost_basis"] | ||
del ledger_entry_record["credit_block"] | ||
ledger_entry_record["block_expiry_date"] = nested_expiry_date | ||
ledger_entry_record["credit_block_per_unit_cost_basis"] = nested_per_unit_cost_basis | ||
|
||
return ledger_entry_record | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @anushree-agrawal would be nice to have a unit test to validate the data transformation here. wydt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I'll add one! |
||
|
||
def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: | ||
|
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add to docstring of the class or the function why you're getting only
committed
records?