mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
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,
|
hidden: true,
|
||||||
description: 'The id of the active slice',
|
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;
|
export default controls;
|
||||||
|
@ -12,7 +12,7 @@ export const sections = {
|
|||||||
controlSetRows: [
|
controlSetRows: [
|
||||||
['datasource'],
|
['datasource'],
|
||||||
['viz_type'],
|
['viz_type'],
|
||||||
['slice_id'],
|
['slice_id', 'cache_timeout'],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
sqlaTimeSeries: {
|
sqlaTimeSeries: {
|
||||||
|
@ -37,7 +37,6 @@ from sqlalchemy_utils import EncryptedType
|
|||||||
from superset import app, db, db_engine_specs, utils, sm
|
from superset import app, db, db_engine_specs, utils, sm
|
||||||
from superset.connectors.connector_registry import ConnectorRegistry
|
from superset.connectors.connector_registry import ConnectorRegistry
|
||||||
from superset.viz import viz_types
|
from superset.viz import viz_types
|
||||||
from superset.utils import QueryStatus
|
|
||||||
from superset.models.helpers import AuditMixinNullable, ImportMixin, set_perm
|
from superset.models.helpers import AuditMixinNullable, ImportMixin, set_perm
|
||||||
install_aliases()
|
install_aliases()
|
||||||
from urllib import parse # noqa
|
from urllib import parse # noqa
|
||||||
@ -181,10 +180,13 @@ class Slice(Model, AuditMixinNullable, ImportMixin):
|
|||||||
@property
|
@property
|
||||||
def form_data(self):
|
def form_data(self):
|
||||||
form_data = json.loads(self.params)
|
form_data = json.loads(self.params)
|
||||||
form_data['slice_id'] = self.id
|
form_data.update({
|
||||||
form_data['viz_type'] = self.viz_type
|
'slice_id': self.id,
|
||||||
form_data['datasource'] = (
|
'viz_type': self.viz_type,
|
||||||
str(self.datasource_id) + '__' + self.datasource_type)
|
'datasource': str(self.datasource_id) + '__' + self.datasource_type
|
||||||
|
})
|
||||||
|
if self.cache_timeout:
|
||||||
|
form_data['cache_timeout'] = self.cache_timeout
|
||||||
return form_data
|
return form_data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -230,7 +232,6 @@ class Slice(Model, AuditMixinNullable, ImportMixin):
|
|||||||
return viz_types[slice_params.get('viz_type')](
|
return viz_types[slice_params.get('viz_type')](
|
||||||
self.datasource,
|
self.datasource,
|
||||||
form_data=slice_params,
|
form_data=slice_params,
|
||||||
slice_=self
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -33,7 +33,7 @@ from superset import (
|
|||||||
sm, sql_lab, results_backend, security,
|
sm, sql_lab, results_backend, security,
|
||||||
)
|
)
|
||||||
from superset.legacy import cast_form_data
|
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
|
from superset.connectors.connector_registry import ConnectorRegistry
|
||||||
import superset.models.core as models
|
import superset.models.core as models
|
||||||
from superset.models.sql_lab import Query
|
from superset.models.sql_lab import Query
|
||||||
@ -47,7 +47,6 @@ from .base import (
|
|||||||
config = app.config
|
config = app.config
|
||||||
log_this = models.Log.log_this
|
log_this = models.Log.log_this
|
||||||
can_access = utils.can_access
|
can_access = utils.can_access
|
||||||
QueryStatus = models.QueryStatus
|
|
||||||
DAR = models.DatasourceAccessRequest
|
DAR = models.DatasourceAccessRequest
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,13 +42,12 @@ class BaseViz(object):
|
|||||||
credits = ""
|
credits = ""
|
||||||
is_timeseries = False
|
is_timeseries = False
|
||||||
|
|
||||||
def __init__(self, datasource, form_data, slice_=None):
|
def __init__(self, datasource, form_data):
|
||||||
if not datasource:
|
if not datasource:
|
||||||
raise Exception("Viz is missing a datasource")
|
raise Exception("Viz is missing a datasource")
|
||||||
self.datasource = datasource
|
self.datasource = datasource
|
||||||
self.request = request
|
self.request = request
|
||||||
self.viz_type = form_data.get("viz_type")
|
self.viz_type = form_data.get("viz_type")
|
||||||
self.slice = slice_
|
|
||||||
self.form_data = form_data
|
self.form_data = form_data
|
||||||
|
|
||||||
self.query = ""
|
self.query = ""
|
||||||
@ -184,9 +183,8 @@ class BaseViz(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def cache_timeout(self):
|
def cache_timeout(self):
|
||||||
|
if self.form_data.get('cache_timeout'):
|
||||||
if self.slice and self.slice.cache_timeout:
|
return int(self.form_data.get('cache_timeout'))
|
||||||
return self.slice.cache_timeout
|
|
||||||
if self.datasource.cache_timeout:
|
if self.datasource.cache_timeout:
|
||||||
return self.datasource.cache_timeout
|
return self.datasource.cache_timeout
|
||||||
if (
|
if (
|
||||||
|
Loading…
Reference in New Issue
Block a user