mirror of https://github.com/apache/superset.git
Slice level cache_timeout isn't taken into consideration (#2631)
This commit is contained in:
parent
70c6cad0e3
commit
23aeee5a9c
|
@ -1199,5 +1199,12 @@ export const controls = {
|
|||
hidden: true,
|
||||
description: 'The id of the active slice',
|
||||
},
|
||||
|
||||
cache_timeout: {
|
||||
type: 'HiddenControl',
|
||||
label: 'Cache Timeout (seconds)',
|
||||
hidden: true,
|
||||
description: 'The number of seconds before expiring the cache',
|
||||
},
|
||||
};
|
||||
export default controls;
|
||||
|
|
|
@ -12,7 +12,7 @@ export const sections = {
|
|||
controlSetRows: [
|
||||
['datasource'],
|
||||
['viz_type'],
|
||||
['slice_id'],
|
||||
['slice_id', 'cache_timeout'],
|
||||
],
|
||||
},
|
||||
sqlaTimeSeries: {
|
||||
|
|
|
@ -37,7 +37,6 @@ from sqlalchemy_utils import EncryptedType
|
|||
from superset import app, db, db_engine_specs, utils, sm
|
||||
from superset.connectors.connector_registry import ConnectorRegistry
|
||||
from superset.viz import viz_types
|
||||
from superset.utils import QueryStatus
|
||||
from superset.models.helpers import AuditMixinNullable, ImportMixin, set_perm
|
||||
install_aliases()
|
||||
from urllib import parse # noqa
|
||||
|
@ -181,10 +180,13 @@ class Slice(Model, AuditMixinNullable, ImportMixin):
|
|||
@property
|
||||
def form_data(self):
|
||||
form_data = json.loads(self.params)
|
||||
form_data['slice_id'] = self.id
|
||||
form_data['viz_type'] = self.viz_type
|
||||
form_data['datasource'] = (
|
||||
str(self.datasource_id) + '__' + self.datasource_type)
|
||||
form_data.update({
|
||||
'slice_id': self.id,
|
||||
'viz_type': self.viz_type,
|
||||
'datasource': str(self.datasource_id) + '__' + self.datasource_type
|
||||
})
|
||||
if self.cache_timeout:
|
||||
form_data['cache_timeout'] = self.cache_timeout
|
||||
return form_data
|
||||
|
||||
@property
|
||||
|
@ -230,7 +232,6 @@ class Slice(Model, AuditMixinNullable, ImportMixin):
|
|||
return viz_types[slice_params.get('viz_type')](
|
||||
self.datasource,
|
||||
form_data=slice_params,
|
||||
slice_=self
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -33,7 +33,7 @@ from superset import (
|
|||
sm, sql_lab, results_backend, security,
|
||||
)
|
||||
from superset.legacy import cast_form_data
|
||||
from superset.utils import has_access
|
||||
from superset.utils import has_access, QueryStatus
|
||||
from superset.connectors.connector_registry import ConnectorRegistry
|
||||
import superset.models.core as models
|
||||
from superset.models.sql_lab import Query
|
||||
|
@ -47,7 +47,6 @@ from .base import (
|
|||
config = app.config
|
||||
log_this = models.Log.log_this
|
||||
can_access = utils.can_access
|
||||
QueryStatus = models.QueryStatus
|
||||
DAR = models.DatasourceAccessRequest
|
||||
|
||||
|
||||
|
|
|
@ -42,13 +42,12 @@ class BaseViz(object):
|
|||
credits = ""
|
||||
is_timeseries = False
|
||||
|
||||
def __init__(self, datasource, form_data, slice_=None):
|
||||
def __init__(self, datasource, form_data):
|
||||
if not datasource:
|
||||
raise Exception("Viz is missing a datasource")
|
||||
self.datasource = datasource
|
||||
self.request = request
|
||||
self.viz_type = form_data.get("viz_type")
|
||||
self.slice = slice_
|
||||
self.form_data = form_data
|
||||
|
||||
self.query = ""
|
||||
|
@ -184,9 +183,8 @@ class BaseViz(object):
|
|||
|
||||
@property
|
||||
def cache_timeout(self):
|
||||
|
||||
if self.slice and self.slice.cache_timeout:
|
||||
return self.slice.cache_timeout
|
||||
if self.form_data.get('cache_timeout'):
|
||||
return int(self.form_data.get('cache_timeout'))
|
||||
if self.datasource.cache_timeout:
|
||||
return self.datasource.cache_timeout
|
||||
if (
|
||||
|
|
Loading…
Reference in New Issue