forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'datahub-project:master' into master
- Loading branch information
Showing
18 changed files
with
284 additions
and
111 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
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
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 |
---|---|---|
|
@@ -54,6 +54,20 @@ def default_user_urn_builder(email: str) -> str: | |
return builder.make_user_urn(email.split("@")[0]) | ||
|
||
|
||
def extract_user_email(user: str) -> Optional[str]: | ||
"""Extracts user email from user input | ||
>>> extract_user_email('urn:li:corpuser:[email protected]') | ||
'[email protected]' | ||
>>> extract_user_email('urn:li:corpuser:abc') | ||
>>> extract_user_email('[email protected]') | ||
'[email protected]' | ||
""" | ||
if user.startswith(("urn:li:corpuser:", "urn:li:corpGroup:")): | ||
user = user.split(":")[-1] | ||
return user if "@" in user else None | ||
|
||
|
||
def make_usage_workunit( | ||
bucket_start_time: datetime, | ||
resource: ResourceType, | ||
|
@@ -104,7 +118,7 @@ def make_usage_workunit( | |
DatasetUserUsageCountsClass( | ||
user=user_urn_builder(user), | ||
count=count, | ||
userEmail=user if "@" in user else None, | ||
userEmail=extract_user_email(user), | ||
) | ||
for user, count in user_freq | ||
], | ||
|
Oops, something went wrong.