Exemple #1
0
def cache_dashboard_thumbnail(dashboard_id: int, force: bool = False) -> None:
    with app.app_context():  # type: ignore
        if not thumbnail_cache:
            logging.warning("No cache set, refusing to compute")
            return None
        logger.info(f"Caching dashboard {dashboard_id}")
        screenshot = DashboardScreenshot(model_id=dashboard_id)
        user = security_manager.find_user(current_app.config["THUMBNAIL_SELENIUM_USER"])
        screenshot.compute_and_cache(user=user, cache=thumbnail_cache, force=force)
Exemple #2
0
def cache_dashboard_thumbnail(
    url: str, digest: str, force: bool = False, thumb_size: Optional[WindowSize] = None
) -> None:
    with app.app_context():  # type: ignore
        if not thumbnail_cache:
            logging.warning("No cache set, refusing to compute")
            return
        logger.info("Caching dashboard: %s", url)
        screenshot = DashboardScreenshot(url, digest)
        user = security_manager.find_user(current_app.config["THUMBNAIL_SELENIUM_USER"])
        screenshot.compute_and_cache(
            user=user, cache=thumbnail_cache, force=force, thumb_size=thumb_size,
        )
Exemple #3
0
def cache_dashboard_thumbnail(url: str,
                              digest: str,
                              force: bool = False,
                              thumb_size: Optional[WindowSize] = None) -> None:
    if not thumbnail_cache:
        logging.warning("No cache set, refusing to compute")
        return
    logger.info("Caching dashboard: %s", url)
    screenshot = DashboardScreenshot(url, digest)
    with session_scope(nullpool=True) as session:
        user = security_manager.get_user_by_username(
            current_app.config["THUMBNAIL_SELENIUM_USER"], session=session)
        screenshot.compute_and_cache(
            user=user,
            cache=thumbnail_cache,
            force=force,
            thumb_size=thumb_size,
        )