diff --git a/sijapi/database.py b/sijapi/database.py index 2b7b5d3..486b02e 100644 --- a/sijapi/database.py +++ b/sijapi/database.py @@ -149,7 +149,7 @@ class Database: result_checksum = hashlib.md5(result_str.encode()).hexdigest() # Add the write query to the query_tracking table - await self.add_query_to_tracking(query, kwargs, result_checksum) + await self.add_query_to_tracking(query, serialized_kwargs, result_checksum) # Initiate async operations asyncio.create_task(self._async_sync_operations()) @@ -173,18 +173,21 @@ 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): async with self.sessions[self.local_ts_id]() as session: new_query = QueryTracking( 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() + async def pull_query_tracking_from_primary(self): primary_ts_id = await self.get_primary_server() if not primary_ts_id: