Total Complexity | 2 |
Total Lines | 21 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from pocketutils.core.query_utils import QueryExecutor |
||
2 | |||
3 | from mandos.model.utils import logger |
||
4 | |||
5 | |||
6 | class _QueryMixin: |
||
7 | @property |
||
8 | def executor(self) -> QueryExecutor: |
||
9 | raise NotImplementedError() |
||
10 | |||
11 | def _query(self, url: str) -> str: |
||
12 | data = self.executor(url) |
||
13 | tt = self.executor.last_time_taken |
||
14 | wt, qt = tt.wait.total_seconds(), tt.query.total_seconds() |
||
15 | bts = int(len(data) * 8 / 1024) |
||
16 | logger.trace(f"Queried {bts} kb from {url} in {qt:.1} s with {wt:.1} s of wait") |
||
17 | return data |
||
18 | |||
19 | |||
20 | __all__ = ["QueryExecutor"] |
||
21 |