@@ -106,26 +106,20 @@ def _dump_used_tables(
106
106
self ._used_tables_crawler .dump_all (processed_tables )
107
107
108
108
def _lint_dashboards (self , context : _ReportingContext ) -> None :
109
- dashboard_ids = self ._dashboard_ids_in_scope ()
110
- logger .info (f"Running { len (dashboard_ids )} linting tasks..." )
111
- for i , dashboard_id in enumerate (dashboard_ids ):
112
- if self ._debug_listing_upper_limit is not None and i >= self ._debug_listing_upper_limit :
113
- logger .warning (f"Debug listing limit reached: { self ._debug_listing_upper_limit } " )
114
- break
109
+ for dashboard_id in self ._dashboard_ids_in_scope ():
115
110
dashboard = self ._ws .dashboards .get (dashboard_id = dashboard_id )
111
+ logger .info (f"Linting dashboard_id={ dashboard_id } : { dashboard .name } " )
116
112
problems , dfsas , tables = self ._lint_and_collect_from_dashboard (dashboard , context .linted_queries )
117
113
context .all_problems .extend (problems )
118
114
context .all_dfsas .extend (dfsas )
119
115
context .all_tables .extend (tables )
120
116
121
117
def _lint_queries (self , context : _ReportingContext ) -> None :
122
- for i , query in enumerate (self ._queries_in_scope ()):
123
- if self ._debug_listing_upper_limit is not None and i >= self ._debug_listing_upper_limit :
124
- logger .warning (f"Debug listing limit reached: { self ._debug_listing_upper_limit } " )
125
- break
118
+ for query in self ._queries_in_scope ():
126
119
assert query .id is not None
127
120
if query .id in context .linted_queries :
128
121
continue
122
+ logger .info (f"Linting query_id={ query .id } : { query .name } " )
129
123
context .linted_queries .add (query .id )
130
124
problems = self .lint_query (query )
131
125
context .all_problems .extend (problems )
@@ -137,14 +131,32 @@ def _lint_queries(self, context: _ReportingContext) -> None:
137
131
def _dashboard_ids_in_scope (self ) -> list [str ]:
138
132
if self ._include_dashboard_ids is not None : # an empty list is accepted
139
133
return self ._include_dashboard_ids
140
- all_dashboards = self ._ws .dashboards .list ()
141
- return [dashboard .id for dashboard in all_dashboards if dashboard .id ]
134
+ items_listed = 0
135
+ dashboard_ids = []
136
+ # redash APIs are very slow to paginate, especially for large number of dashboards, so we limit the listing
137
+ # to a small number of items in debug mode for the assessment workflow just to complete.
138
+ for dashboard in self ._ws .dashboards .list ():
139
+ if self ._debug_listing_upper_limit is not None and items_listed >= self ._debug_listing_upper_limit :
140
+ logger .warning (f"Debug listing limit reached: { self ._debug_listing_upper_limit } " )
141
+ break
142
+ if dashboard .id is None :
143
+ continue
144
+ dashboard_ids .append (dashboard .id )
145
+ items_listed += 1
146
+ return dashboard_ids
142
147
143
148
def _queries_in_scope (self ) -> list [LegacyQuery ]:
144
149
if self ._include_dashboard_ids is not None : # an empty list is accepted
145
150
return []
146
- all_queries = self ._ws .queries_legacy .list ()
147
- return [query for query in all_queries if query .id ]
151
+ items_listed = 0
152
+ legacy_queries = []
153
+ for query in self ._ws .queries_legacy .list ():
154
+ if self ._debug_listing_upper_limit is not None and items_listed >= self ._debug_listing_upper_limit :
155
+ logger .warning (f"Debug listing limit reached: { self ._debug_listing_upper_limit } " )
156
+ break
157
+ legacy_queries .append (query )
158
+ items_listed += 1
159
+ return legacy_queries
148
160
149
161
def _lint_and_collect_from_dashboard (
150
162
self , dashboard : Dashboard , linted_queries : set [str ]
0 commit comments