-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(ingest/tableau): prevent empty site content urls #11057
Changes from all commits
3f20cc6
55de7a1
9c74076
ddc66f1
e1261cd
e150791
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -757,6 +757,12 @@ def _re_authenticate(self): | |||||||||||||||||||||
] = self.config.get_tableau_auth(self.site.content_url) | ||||||||||||||||||||||
self.server.auth.sign_in(tableau_auth) | ||||||||||||||||||||||
|
||||||||||||||||||||||
@property | ||||||||||||||||||||||
def site_content_url(self) -> Optional[str]: | ||||||||||||||||||||||
if self.site and self.site.content_url: | ||||||||||||||||||||||
return self.site.content_url | ||||||||||||||||||||||
return None | ||||||||||||||||||||||
|
||||||||||||||||||||||
def _populate_usage_stat_registry(self) -> None: | ||||||||||||||||||||||
if self.server is None: | ||||||||||||||||||||||
return | ||||||||||||||||||||||
|
@@ -2524,7 +2530,9 @@ def emit_sheets_as_charts( | |||||||||||||||||||||
last_modified = self.get_last_modified(creator, created_at, updated_at) | ||||||||||||||||||||||
|
||||||||||||||||||||||
if sheet.get(c.PATH): | ||||||||||||||||||||||
site_part = f"/site/{self.site.content_url}" if self.site else "" | ||||||||||||||||||||||
site_part = ( | ||||||||||||||||||||||
f"/site/{self.site_content_url}" if self.site_content_url else "" | ||||||||||||||||||||||
) | ||||||||||||||||||||||
sheet_external_url = ( | ||||||||||||||||||||||
f"{self.config.connect_uri}/#{site_part}/views/{sheet.get(c.PATH)}" | ||||||||||||||||||||||
) | ||||||||||||||||||||||
|
@@ -2535,7 +2543,7 @@ def emit_sheets_as_charts( | |||||||||||||||||||||
and sheet[c.CONTAINED_IN_DASHBOARDS][0].get(c.PATH) | ||||||||||||||||||||||
): | ||||||||||||||||||||||
# sheet contained in dashboard | ||||||||||||||||||||||
site_part = f"/t/{self.site.content_url}" if self.site else "" | ||||||||||||||||||||||
site_part = f"/t/{self.site_content_url}" if self.site_content_url else "" | ||||||||||||||||||||||
dashboard_path = sheet[c.CONTAINED_IN_DASHBOARDS][0][c.PATH] | ||||||||||||||||||||||
sheet_external_url = f"{self.config.connect_uri}{site_part}/authoring/{dashboard_path}/{quote(sheet.get(c.NAME, ''), safe='')}" | ||||||||||||||||||||||
else: | ||||||||||||||||||||||
|
@@ -2667,7 +2675,7 @@ def emit_workbook_as_container(self, workbook: Dict) -> Iterable[MetadataWorkUni | |||||||||||||||||||||
else None | ||||||||||||||||||||||
) | ||||||||||||||||||||||
|
||||||||||||||||||||||
site_part = f"/site/{self.site.content_url}" if self.site else "" | ||||||||||||||||||||||
site_part = f"/site/{self.site_content_url}" if self.site_content_url else "" | ||||||||||||||||||||||
workbook_uri = workbook.get("uri") | ||||||||||||||||||||||
workbook_part = ( | ||||||||||||||||||||||
Comment on lines
+2678
to
2680
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. Simplify URL construction logic. The logic for constructing - site_part = f"/site/{self.site_content_url}" if self.site_content_url else ""
- workbook_uri = workbook.get("uri")
- workbook_part = workbook_uri[workbook_uri.index("/workbooks/") :] if workbook_uri else None
+ workbook_uri = workbook.get("uri")
+ if workbook_uri:
+ site_part = f"/site/{self.site_content_url}" if self.site_content_url else ""
+ workbook_part = workbook_uri[workbook_uri.index("/workbooks/") :]
+ workbook_external_url = f"{self.config.connect_uri}/#{site_part}{workbook_part}"
+ else:
+ workbook_external_url = None Committable suggestion
Suggested change
|
||||||||||||||||||||||
workbook_uri[workbook_uri.index("/workbooks/") :] if workbook_uri else None | ||||||||||||||||||||||
|
@@ -2826,7 +2834,7 @@ def emit_dashboard( | |||||||||||||||||||||
updated_at = dashboard.get(c.UPDATED_AT, datetime.now()) | ||||||||||||||||||||||
last_modified = self.get_last_modified(creator, created_at, updated_at) | ||||||||||||||||||||||
|
||||||||||||||||||||||
site_part = f"/site/{self.site.content_url}" if self.site else "" | ||||||||||||||||||||||
site_part = f"/site/{self.site_content_url}" if self.site_content_url else "" | ||||||||||||||||||||||
dashboard_external_url = ( | ||||||||||||||||||||||
f"{self.config.connect_uri}/#{site_part}/views/{dashboard.get(c.PATH, '')}" | ||||||||||||||||||||||
) | ||||||||||||||||||||||
|
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.
Seems like we always use this in a ternary. Could we just return
""
instead and avoid the ternary?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.
not really - sometimes we need
/site/{self.site_content_url}
, but sometimes the prefix is/t/
instead of site