fix(thumbnails): missing field, logging and new config var (#10562)

* fix(thumbnails): missing field, logging and new config var

* deprecate EMAIL_REPORTS_WEBDRIVER

* fix after merge and conflicts

* fix tests

* black
This commit is contained in:
Daniel Vaz Gaspar 2020-08-14 14:12:44 +01:00 committed by GitHub
parent db88cec431
commit 4dd1d1df5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 37 deletions

View File

@ -23,6 +23,8 @@ assists people when migrating to a new version.
## Next ## Next
* [10562](https://github.com/apache/incubator-superset/pull/10562): EMAIL_REPORTS_WEBDRIVER is deprecated use WEBDRIVER_TYPE instead.
* [10567](https://github.com/apache/incubator-superset/pull/10567): Default WEBDRIVER_OPTION_ARGS are Chrome-specific. If you're using FF, should be `--headless` only * [10567](https://github.com/apache/incubator-superset/pull/10567): Default WEBDRIVER_OPTION_ARGS are Chrome-specific. If you're using FF, should be `--headless` only
* [10241](https://github.com/apache/incubator-superset/pull/10241): change on Alpha role, users started to have access to "Annotation Layers", "Css Templates" and "Import Dashboards". * [10241](https://github.com/apache/incubator-superset/pull/10241): change on Alpha role, users started to have access to "Annotation Layers", "Css Templates" and "Import Dashboards".

View File

@ -86,38 +86,39 @@ class ChartRestApi(BaseSupersetModelRestApi):
} }
class_permission_name = "SliceModelView" class_permission_name = "SliceModelView"
show_columns = [ show_columns = [
"slice_name",
"description",
"owners.id",
"owners.username",
"owners.first_name",
"owners.last_name",
"dashboards.id",
"dashboards.dashboard_title",
"viz_type",
"params",
"cache_timeout", "cache_timeout",
"dashboards.dashboard_title",
"dashboards.id",
"description",
"owners.first_name",
"owners.id",
"owners.last_name",
"owners.username",
"params",
"slice_name",
"viz_type",
] ]
show_select_columns = show_columns + ["table.id"] show_select_columns = show_columns + ["table.id"]
list_columns = [ list_columns = [
"id", "cache_timeout",
"slice_name",
"url",
"description",
"changed_by_name",
"changed_by_url",
"changed_by.first_name", "changed_by.first_name",
"changed_by.last_name", "changed_by.last_name",
"changed_on_utc", "changed_by_name",
"changed_by_url",
"changed_on_delta_humanized", "changed_on_delta_humanized",
"changed_on_utc",
"datasource_id", "datasource_id",
"datasource_type",
"datasource_name_text", "datasource_name_text",
"datasource_type",
"datasource_url", "datasource_url",
"description",
"id",
"params",
"slice_name",
"table.default_endpoint", "table.default_endpoint",
"table.table_name", "table.table_name",
"thumbnail_url", "thumbnail_url",
"viz_type", "url",
"params", "params",
"cache_timeout", "cache_timeout",
"owners.id", "owners.id",
@ -125,24 +126,24 @@ class ChartRestApi(BaseSupersetModelRestApi):
"owners.first_name", "owners.first_name",
"owners.last_name", "owners.last_name",
] ]
list_select_columns = list_columns + ["changed_on", "changed_by_fk"] list_select_columns = list_columns + ["changed_by_fk", "changed_on"]
order_columns = [ order_columns = [
"slice_name",
"viz_type",
"datasource_name",
"datasource_id",
"changed_by.first_name", "changed_by.first_name",
"changed_on_delta_humanized", "changed_on_delta_humanized",
]
search_columns = (
"slice_name",
"description",
"viz_type",
"datasource_name",
"datasource_id", "datasource_id",
"datasource_name",
"slice_name",
"viz_type",
]
search_columns = [
"datasource_id",
"datasource_name",
"datasource_type", "datasource_type",
"description",
"owners", "owners",
) "slice_name",
"viz_type",
]
base_order = ("changed_on", "desc") base_order = ("changed_on", "desc")
base_filters = [["id", ChartFilter, lambda: []]] base_filters = [["id", ChartFilter, lambda: []]]
search_filters = {"slice_name": [ChartNameOrDescriptionFilter]} search_filters = {"slice_name": [ChartNameOrDescriptionFilter]}

View File

@ -795,7 +795,7 @@ EMAIL_REPORTS_SUBJECT_PREFIX = "[Report] "
# chrome: # chrome:
# Requires: headless chrome # Requires: headless chrome
# Limitations: unable to generate screenshots of elements # Limitations: unable to generate screenshots of elements
EMAIL_REPORTS_WEBDRIVER = "firefox" WEBDRIVER_TYPE = "firefox"
# Window size - this will impact the rendering of the data # Window size - this will impact the rendering of the data
WEBDRIVER_WINDOW = {"dashboard": (1600, 2000), "slice": (3000, 1200)} WEBDRIVER_WINDOW = {"dashboard": (1600, 2000), "slice": (3000, 1200)}

View File

@ -199,9 +199,7 @@ def _get_url_path(view: str, user_friendly: bool = False, **kwargs: Any) -> str:
def create_webdriver() -> WebDriver: def create_webdriver() -> WebDriver:
return WebDriverProxy(driver_type=config["EMAIL_REPORTS_WEBDRIVER"]).auth( return WebDriverProxy(driver_type=config["WEBDRIVER_TYPE"]).auth(get_reports_user())
get_reports_user()
)
def get_reports_user() -> "User": def get_reports_user() -> "User":

View File

@ -42,7 +42,7 @@ def cache_chart_thumbnail(
if not thumbnail_cache: if not thumbnail_cache:
logger.warning("No cache set, refusing to compute") logger.warning("No cache set, refusing to compute")
return None return None
logging.info("Caching chart at {url}") logger.info("Caching chart: %s", url)
screenshot = ChartScreenshot(url, digest) screenshot = ChartScreenshot(url, digest)
user = security_manager.find_user(current_app.config["THUMBNAIL_SELENIUM_USER"]) user = security_manager.find_user(current_app.config["THUMBNAIL_SELENIUM_USER"])
screenshot.compute_and_cache( screenshot.compute_and_cache(

View File

@ -37,7 +37,7 @@ if TYPE_CHECKING:
class BaseScreenshot: class BaseScreenshot:
driver_type = current_app.config.get("EMAIL_REPORTS_WEBDRIVER", "chrome") driver_type = current_app.config["WEBDRIVER_TYPE"]
thumbnail_type: str = "" thumbnail_type: str = ""
element: str = "" element: str = ""
window_size: WindowSize = (800, 600) window_size: WindowSize = (800, 600)