|
1 | 1 | """Serveradmin - Query Executer |
2 | 2 |
|
3 | | -Copyright (c) 2019 InnoGames GmbH |
| 3 | +Copyright (c) 2025 InnoGames GmbH |
4 | 4 | """ |
5 | 5 |
|
| 6 | +import logging |
| 7 | +import time |
| 8 | + |
6 | 9 | from django.core.exceptions import ObjectDoesNotExist, ValidationError |
7 | 10 | from django.db import DataError, connection, transaction |
8 | 11 |
|
9 | 12 | from adminapi.filters import Any |
| 13 | +from adminapi.parse import build_query |
10 | 14 | from serveradmin.serverdb.models import Attribute, ServertypeAttribute, Server |
11 | 15 | from serveradmin.serverdb.query_builder import get_server_query |
12 | 16 | from serveradmin.serverdb.query_materializer import QueryMaterializer |
|
15 | 19 | def execute_query(filters, restrict, order_by): |
16 | 20 | """The main function to execute queries""" |
17 | 21 |
|
| 22 | + start = time.time() |
| 23 | + |
18 | 24 | # We need the restrict argument in slightly different structure. |
19 | 25 | if restrict is None: |
20 | 26 | joins = None |
@@ -98,7 +104,12 @@ def cast(join): |
98 | 104 | # materializer module for its details. The functions on this module |
99 | 105 | # continues with the filtering step. |
100 | 106 | servers = _get_servers(filters, attribute_lookup, related_vias) |
101 | | - return list(QueryMaterializer(servers, *materializer_args)) |
| 107 | + result = list(QueryMaterializer(servers, *materializer_args)) |
| 108 | + |
| 109 | + duration = time.time() - start |
| 110 | + logging.getLogger('queries').debug(f"{build_query(filters)};{duration:.3f}s;{len(result)}") |
| 111 | + |
| 112 | + return result |
102 | 113 |
|
103 | 114 |
|
104 | 115 | def _get_joins(restrict): |
|
0 commit comments