Auto-update: Mon Aug 12 22:31:07 PDT 2024
This commit is contained in:
parent
e8c6233223
commit
27f4beb50c
1 changed files with 9 additions and 4 deletions
|
@ -53,9 +53,10 @@ class QueryTracking(Base):
|
|||
query = Column(Text, nullable=False)
|
||||
args = Column(JSONB)
|
||||
executed_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
completed_by = Column(ARRAY(String), default=[])
|
||||
completed_by = Column(JSONB, default={})
|
||||
result_checksum = Column(String(32))
|
||||
|
||||
|
||||
class Database:
|
||||
@classmethod
|
||||
def init(cls, config_name: str):
|
||||
|
@ -169,18 +170,22 @@ class Database:
|
|||
l.error(f"Error in async sync operations: {str(e)}")
|
||||
l.error(f"Traceback: {traceback.format_exc()}")
|
||||
|
||||
async def add_query_to_tracking(self, query: str, kwargs: dict):
|
||||
|
||||
|
||||
async def add_query_to_tracking(self, query: str, kwargs: dict, result_checksum: str = None):
|
||||
async with self.sessions[self.local_ts_id]() as session:
|
||||
new_query = QueryTracking(
|
||||
ts_id=self.local_ts_id,
|
||||
origin_ts_id=self.local_ts_id,
|
||||
query=query,
|
||||
args=json_dumps(kwargs),
|
||||
completed_by={self.local_ts_id: True}
|
||||
completed_by={self.local_ts_id: True},
|
||||
result_checksum=result_checksum
|
||||
)
|
||||
session.add(new_query)
|
||||
await session.commit()
|
||||
l.info(f"Added query to tracking: {query[:50]}...")
|
||||
|
||||
|
||||
async def sync_db(self):
|
||||
current_time = time.time()
|
||||
if current_time - self.last_sync_time < 30:
|
||||
|
|
Loading…
Reference in a new issue