Skip to content

Commit

Permalink
fix: add __init__.py to key_value (#17730)
Browse files Browse the repository at this point in the history
* Add __init__.py

* Lisence

* Linter

Co-authored-by: Bogdan Kyryliuk <bogdankyryliuk@dropbox.com>
  • Loading branch information
bkyryliuk and bogdan-dbx committed Dec 15, 2021
1 parent 6d97e89 commit ec24256
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions superset/dashboards/filter_state/commands/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@


class GetFilterStateCommand(GetKeyValueCommand):
def get(self, resource_id: int, key: str, refreshTimeout: bool) -> Optional[str]:
def get(self, resource_id: int, key: str, refresh_timeout: bool) -> Optional[str]:
dashboard = DashboardDAO.get_by_id_or_slug(str(resource_id))
if dashboard:
entry: Entry = cache_manager.filter_state_cache.get(
cache_key(resource_id, key)
)
if refreshTimeout:
if refresh_timeout:
cache_manager.filter_state_cache.set(key, entry)
return entry["value"]
return None
16 changes: 16 additions & 0 deletions superset/key_value/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
6 changes: 3 additions & 3 deletions superset/key_value/commands/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def __init__(self, actor: User, resource_id: int, key: str):
def run(self) -> Model:
try:
config = app.config["FILTER_STATE_CACHE_CONFIG"]
refreshTimeout = config.get("REFRESH_TIMEOUT_ON_RETRIEVAL")
return self.get(self._resource_id, self._key, refreshTimeout)
refresh_timeout = config.get("REFRESH_TIMEOUT_ON_RETRIEVAL")
return self.get(self._resource_id, self._key, refresh_timeout)
except SQLAlchemyError as ex:
logger.exception("Error running get command")
raise KeyValueGetFailedError() from ex
Expand All @@ -48,5 +48,5 @@ def validate(self) -> None:
pass

@abstractmethod
def get(self, resource_id: int, key: str, refreshTimeout: bool) -> Optional[str]:
def get(self, resource_id: int, key: str, refresh_timeout: bool) -> Optional[str]:
...

0 comments on commit ec24256

Please sign in to comment.