|
|
@ -2,6 +2,7 @@ from typing import List |
|
|
from pymongo.asynchronous.database import AsyncDatabase |
|
|
from pymongo.asynchronous.database import AsyncDatabase |
|
|
from typing import List |
|
|
from typing import List |
|
|
from entities.PacketGroup import PacketGroup |
|
|
from entities.PacketGroup import PacketGroup |
|
|
|
|
|
from entities.PacketSignal import PacketSignal |
|
|
|
|
|
|
|
|
class NodeDbService: |
|
|
class NodeDbService: |
|
|
def __init__(self, dbStore): |
|
|
def __init__(self, dbStore): |
|
|
@ -92,6 +93,30 @@ class PacketDbService: |
|
|
def __init__(self, dbStore): |
|
|
def __init__(self, dbStore): |
|
|
self.dbStore:AsyncDatabase = dbStore |
|
|
self.dbStore:AsyncDatabase = dbStore |
|
|
|
|
|
|
|
|
|
|
|
async def findPacketsSignals(self, |
|
|
|
|
|
after: float = -1, |
|
|
|
|
|
before: float = -1, |
|
|
|
|
|
nums: List[int] = []): |
|
|
|
|
|
pipeline = [] |
|
|
|
|
|
match = {} |
|
|
|
|
|
if after != -1 or before != -1: |
|
|
|
|
|
match["ts"] = {} |
|
|
|
|
|
if after != -1: |
|
|
|
|
|
match["ts"]["$gt"] = after |
|
|
|
|
|
if before != -1: |
|
|
|
|
|
match["ts"]["$lt"] = before |
|
|
|
|
|
|
|
|
|
|
|
if nums: |
|
|
|
|
|
if type(nums) != list: |
|
|
|
|
|
nums = [nums] |
|
|
|
|
|
match["from"] = {"$in":nums} |
|
|
|
|
|
|
|
|
|
|
|
pipeline.append({"$match":match}) |
|
|
|
|
|
collection = self.dbStore['packet'] |
|
|
|
|
|
c = await collection.aggregate(pipeline) |
|
|
|
|
|
l = await c.to_list() |
|
|
|
|
|
return [PacketSignal(p) for p in l] |
|
|
|
|
|
|
|
|
async def findPacketsAndGroupCount(self, |
|
|
async def findPacketsAndGroupCount(self, |
|
|
after: float = -1, |
|
|
after: float = -1, |
|
|
before: float = -1, |
|
|
before: float = -1, |
|
|
|