Production improvements
This commit is contained in:
parent
7bd2e89070
commit
378047e622
5 changed files with 21 additions and 7 deletions
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Sequence, Tuple
|
||||
|
||||
from pymongo import MongoClient
|
||||
from pymongo import ASCENDING, DESCENDING, MongoClient
|
||||
|
||||
from ..utilities import chunk
|
||||
from ..views import Filter, SortBy, Trace
|
||||
|
|
@ -31,6 +31,11 @@ class MongodbDriver(TracingDatabaseDriver):
|
|||
"Please configure the MongoDB access options by calling MongodbDriver.configure_credentials"
|
||||
)
|
||||
|
||||
with MongoClient[Any](self.mongo_connection_string) as client:
|
||||
client[self.mongo_database].traces.create_index(
|
||||
[("tags", ASCENDING), ("created", DESCENDING)], background=True
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def configure_credentials( # type: ignore
|
||||
cls,
|
||||
|
|
@ -93,11 +98,13 @@ class MongodbDriver(TracingDatabaseDriver):
|
|||
"filter": {},
|
||||
}
|
||||
|
||||
and_query: List[Dict[str, Any]] = [{}]
|
||||
and_query: List[Dict[str, Any]] = []
|
||||
and_query.extend({"tags": tag} for tag in conjunctive_tags)
|
||||
and_query.extend(
|
||||
{f.property: {self._get_operator(f): f.value}} for f in conjunctive_filters
|
||||
)
|
||||
if not and_query:
|
||||
and_query.append({})
|
||||
|
||||
if since:
|
||||
and_query.append({"created": {"$gte": since}})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue