|
29 | 29 | # - We currently don't support maps because they are clickable and would require a more evolved cheat function |
30 | 30 | SUPPORTED_PLOT_TYPES = ["area", "bar", "column", "line", "pie", "spline"] |
31 | 31 |
|
32 | | -# Get report filter config |
33 | | -config = SNowInstance().report_filter_config |
34 | | -if config is None: |
35 | | - REPORT_DATE_FILTER = REPORT_TIME_FILTER = None |
36 | | -else: |
37 | | - REPORT_DATE_FILTER = config["report_date_filter"] |
38 | | - REPORT_TIME_FILTER = config["report_time_filter"] |
39 | | -del config |
40 | | - |
41 | 32 |
|
42 | 33 | class DashboardRetrievalTask(AbstractServiceNowTask, ABC): |
43 | 34 | """ |
@@ -303,14 +294,28 @@ def get_init_scripts(self) -> List[str]: |
303 | 294 | """, |
304 | 295 | ] |
305 | 296 |
|
306 | | - def setup_goal(self, page: playwright.sync_api.Page) -> Tuple[str | dict]: |
307 | | - super().setup_goal(page=page) |
| 297 | + def _get_filter_config(self) -> str: |
| 298 | + # Get report filter config |
| 299 | + config = self.instance.report_filter_config |
| 300 | + if config is None: |
| 301 | + REPORT_DATE_FILTER = REPORT_TIME_FILTER = None |
| 302 | + else: |
| 303 | + REPORT_DATE_FILTER = config["report_date_filter"] |
| 304 | + REPORT_TIME_FILTER = config["report_time_filter"] |
| 305 | + del config |
308 | 306 |
|
309 | 307 | # Check that the report filters are properly setup |
310 | 308 | if REPORT_DATE_FILTER is None or REPORT_TIME_FILTER is None: |
311 | 309 | raise RuntimeError( |
312 | 310 | "The report date and time filters are not set. Please run the install script to set them." |
313 | 311 | ) |
| 312 | + return REPORT_DATE_FILTER, REPORT_TIME_FILTER |
| 313 | + |
| 314 | + def setup_goal(self, page: playwright.sync_api.Page) -> Tuple[str | dict]: |
| 315 | + super().setup_goal(page=page) |
| 316 | + |
| 317 | + # Get the instance report filter config |
| 318 | + REPORT_DATE_FILTER, REPORT_TIME_FILTER = self._get_filter_config() |
314 | 319 |
|
315 | 320 | # Configure task |
316 | 321 | # ... sample a configuration |
@@ -632,6 +637,9 @@ def _generate_random_config( |
632 | 637 | The types of questions to sample from (uniformely) |
633 | 638 |
|
634 | 639 | """ |
| 640 | + # Get the instance report filter config |
| 641 | + REPORT_DATE_FILTER, REPORT_TIME_FILTER = self._get_filter_config() |
| 642 | + |
635 | 643 | # Check that the report filters are properly setup |
636 | 644 | if REPORT_DATE_FILTER is None or REPORT_TIME_FILTER is None: |
637 | 645 | raise RuntimeError( |
|
0 commit comments