Coverage for django_query_capture/presenter/only_slow_query.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-11-20 10:20 +0000

1from django_query_capture.presenter.base import BasePresenter 

2from django_query_capture.utils import colorize, get_stack_prefix 

3 

4 

5class OnlySlowQueryPresenter(BasePresenter): 

6 """ 

7 Only queries exceeding the [SLOW_MIN_SECOND](../../home/settings.md) threshold are output. 

8 """ 

9 

10 def print(self) -> None: 

11 for captured_query in self.classified_query["slow_captured_queries"]: 

12 print( 

13 colorize( 

14 f'{get_stack_prefix(captured_query)} Slow {captured_query["duration"]:.2f} seconds', 

15 is_warning=True, 

16 ) 

17 )