add lru cache to property

This commit is contained in:
Daniel Gaspar
2020-09-10 12:22:58 +01:00
parent 009bcff665
commit ad0d942814

View File

@@ -17,6 +17,7 @@
"""A collection of ORM sqlalchemy models for SQL Lab"""
import re
from datetime import datetime
from functools import lru_cache
from typing import Any, Dict, List
import simplejson as json
@@ -204,6 +205,7 @@ class SavedQuery(Model, AuditMixinNullable, ExtraJSONMixin):
return "/superset/sqllab?savedQueryId={0}".format(self.id)
@property
@lru_cache(maxsize=2)
def sql_tables(self) -> List[Table]:
return list(ParsedQuery(self.sql).tables)