mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
This reverts commit 7645fc85c3.
This commit is contained in:
@@ -134,7 +134,8 @@ class DummyStrategy(Strategy):
|
||||
name = "dummy"
|
||||
|
||||
def get_urls(self) -> List[str]:
|
||||
charts = db.session.query(Slice).all()
|
||||
session = db.create_scoped_session()
|
||||
charts = session.query(Slice).all()
|
||||
|
||||
return [get_url(chart) for chart in charts]
|
||||
|
||||
@@ -166,9 +167,10 @@ class TopNDashboardsStrategy(Strategy):
|
||||
|
||||
def get_urls(self) -> List[str]:
|
||||
urls = []
|
||||
session = db.create_scoped_session()
|
||||
|
||||
records = (
|
||||
db.session.query(Log.dashboard_id, func.count(Log.dashboard_id))
|
||||
session.query(Log.dashboard_id, func.count(Log.dashboard_id))
|
||||
.filter(and_(Log.dashboard_id.isnot(None), Log.dttm >= self.since))
|
||||
.group_by(Log.dashboard_id)
|
||||
.order_by(func.count(Log.dashboard_id).desc())
|
||||
@@ -176,9 +178,7 @@ class TopNDashboardsStrategy(Strategy):
|
||||
.all()
|
||||
)
|
||||
dash_ids = [record.dashboard_id for record in records]
|
||||
dashboards = (
|
||||
db.session.query(Dashboard).filter(Dashboard.id.in_(dash_ids)).all()
|
||||
)
|
||||
dashboards = session.query(Dashboard).filter(Dashboard.id.in_(dash_ids)).all()
|
||||
for dashboard in dashboards:
|
||||
for chart in dashboard.slices:
|
||||
form_data_with_filters = get_form_data(chart.id, dashboard)
|
||||
@@ -211,13 +211,14 @@ class DashboardTagsStrategy(Strategy):
|
||||
|
||||
def get_urls(self) -> List[str]:
|
||||
urls = []
|
||||
session = db.create_scoped_session()
|
||||
|
||||
tags = db.session.query(Tag).filter(Tag.name.in_(self.tags)).all()
|
||||
tags = session.query(Tag).filter(Tag.name.in_(self.tags)).all()
|
||||
tag_ids = [tag.id for tag in tags]
|
||||
|
||||
# add dashboards that are tagged
|
||||
tagged_objects = (
|
||||
db.session.query(TaggedObject)
|
||||
session.query(TaggedObject)
|
||||
.filter(
|
||||
and_(
|
||||
TaggedObject.object_type == "dashboard",
|
||||
@@ -227,16 +228,14 @@ class DashboardTagsStrategy(Strategy):
|
||||
.all()
|
||||
)
|
||||
dash_ids = [tagged_object.object_id for tagged_object in tagged_objects]
|
||||
tagged_dashboards = db.session.query(Dashboard).filter(
|
||||
Dashboard.id.in_(dash_ids)
|
||||
)
|
||||
tagged_dashboards = session.query(Dashboard).filter(Dashboard.id.in_(dash_ids))
|
||||
for dashboard in tagged_dashboards:
|
||||
for chart in dashboard.slices:
|
||||
urls.append(get_url(chart))
|
||||
|
||||
# add charts that are tagged
|
||||
tagged_objects = (
|
||||
db.session.query(TaggedObject)
|
||||
session.query(TaggedObject)
|
||||
.filter(
|
||||
and_(
|
||||
TaggedObject.object_type == "chart",
|
||||
@@ -246,7 +245,7 @@ class DashboardTagsStrategy(Strategy):
|
||||
.all()
|
||||
)
|
||||
chart_ids = [tagged_object.object_id for tagged_object in tagged_objects]
|
||||
tagged_charts = db.session.query(Slice).filter(Slice.id.in_(chart_ids))
|
||||
tagged_charts = session.query(Slice).filter(Slice.id.in_(chart_ids))
|
||||
for chart in tagged_charts:
|
||||
urls.append(get_url(chart))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user