updated Parser comment
This commit is contained in:
@@ -138,6 +138,7 @@ class ConfigServices:
|
||||
TASK_UUID_INDEX_PREFIX: str = "BANK:SERVICES:TASK:UUID"
|
||||
TASK_SEEN_PREFIX: str = "BANK:SERVICES:TASK:SEEN"
|
||||
TASK_DELETED_PREFIX: str = "BANK:SERVICES:TASK:DELETED"
|
||||
TASK_COMMENT_PARSER: str = "BANK:SERVICES:TASK:COMMENT:PARSER"
|
||||
|
||||
SERVICE_PREFIX_MAIL_READER: str = "MailReader"
|
||||
SERVICE_PREFIX_MAIL_PARSER: str = "MailParser"
|
||||
@@ -145,6 +146,7 @@ class ConfigServices:
|
||||
SERVICE_PREFIX_FINDER_COMMENT: str = "FinderComment"
|
||||
SERVICE_PREFIX_MAIL_SENDER: str = "MailSender"
|
||||
|
||||
|
||||
TEMPLATE_ACCOUNT_RECORDS: str = "template_accounts.html"
|
||||
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ class PrismaService:
|
||||
table_selected: BaseModelClient = getattr(db, table, None)
|
||||
if not table_selected:
|
||||
raise ValueError(f"Table {table} not found")
|
||||
rows = await table_selected.find_many(where=query, take=take, skip=skip, order=order or [], select=select, include=include)
|
||||
rows = await table_selected.find_many(where=query, take=take, skip=skip, order=order or [], include=include)
|
||||
# print(f"[{datetime.now()}] Find many query completed in {time.time() - start:.2f}s")
|
||||
return rows
|
||||
|
||||
@@ -234,7 +234,7 @@ class PrismaService:
|
||||
self, table: str, query: Optional[dict] = None, take: int = None, skip: int = None,
|
||||
order: Optional[list[dict]] = None, select: Optional[dict] = None, include: Optional[dict] = None
|
||||
):
|
||||
result = self._submit(self._a_find_many(table=table, query=query, take=take, skip=skip, order=order, select=select, include=include))
|
||||
result = self._submit(self._a_find_many(table=table, query=query, take=take, skip=skip, order=order, include=include))
|
||||
if select and result:
|
||||
result = [{k: v for k, v in item.items() if k in select} for item in result]
|
||||
return result
|
||||
|
||||
@@ -605,15 +605,6 @@ class MailReaderService:
|
||||
self.service_retriever = ServiceTaskRetriever(self.redis_handler)
|
||||
self._initialized = True
|
||||
|
||||
def ensure_connection(self):
|
||||
"""
|
||||
Ensure Redis connection is established
|
||||
|
||||
Returns:
|
||||
bool: True if connection is established, False otherwise
|
||||
"""
|
||||
return self.redis_handler.ensure_connection()
|
||||
|
||||
def get_task_by_uuid(self, task_uuid: str) -> RedisTaskObject:
|
||||
"""
|
||||
Get a task object by its UUID
|
||||
@@ -840,34 +831,6 @@ class MailParserService:
|
||||
def fetch_all_tasks(self) -> list[RedisTaskObject]:
|
||||
return self.service_retriever.fetch_all_tasks()
|
||||
|
||||
def ensure_connection(self):
|
||||
"""
|
||||
Ensure Redis connection is established
|
||||
|
||||
Returns:
|
||||
bool: True if connection is established, False otherwise
|
||||
"""
|
||||
return self.redis_handler.ensure_connection()
|
||||
|
||||
def _check_redis_connection(self) -> bool:
|
||||
"""
|
||||
Check if Redis connection is alive using RedisHandler
|
||||
|
||||
Returns:
|
||||
True if connection is alive, False otherwise
|
||||
"""
|
||||
try:
|
||||
# Use RedisHandler to check connection
|
||||
connection_status = self.redis_handler.ensure_connection()
|
||||
if connection_status:
|
||||
logger.info("Redis connection established via RedisHandler")
|
||||
else:
|
||||
logger.error("Redis connection check failed via RedisHandler")
|
||||
return connection_status
|
||||
except RedisHandler.REDIS_EXCEPTIONS as e:
|
||||
logger.error(f"Redis connection failed: {str(e)}")
|
||||
return False
|
||||
|
||||
def get_task_by_uuid(self, task_uuid: str) -> RedisTaskObject:
|
||||
"""
|
||||
Get a task object by its UUID
|
||||
@@ -948,34 +911,6 @@ class IbanFinderService:
|
||||
def fetch_all_tasks(self) -> list[RedisTaskObject]:
|
||||
return self.service_retriever.fetch_all_tasks()
|
||||
|
||||
def ensure_connection(self):
|
||||
"""
|
||||
Ensure Redis connection is established
|
||||
|
||||
Returns:
|
||||
bool: True if connection is established, False otherwise
|
||||
"""
|
||||
return self.redis_handler.ensure_connection()
|
||||
|
||||
def _check_redis_connection(self) -> bool:
|
||||
"""
|
||||
Check if Redis connection is alive using RedisHandler
|
||||
|
||||
Returns:
|
||||
True if connection is alive, False otherwise
|
||||
"""
|
||||
try:
|
||||
# Use RedisHandler to check connection
|
||||
connection_status = self.redis_handler.ensure_connection()
|
||||
if connection_status:
|
||||
logger.info("Redis connection established via RedisHandler")
|
||||
else:
|
||||
logger.error("Redis connection check failed via RedisHandler")
|
||||
return connection_status
|
||||
except RedisHandler.REDIS_EXCEPTIONS as e:
|
||||
logger.error(f"Redis connection failed: {str(e)}")
|
||||
return False
|
||||
|
||||
def get_task_by_uuid(self, task_uuid: str) -> RedisTaskObject:
|
||||
"""
|
||||
Get a task object by its UUID
|
||||
@@ -1152,3 +1087,41 @@ class ProcessCommentFinderService:
|
||||
return self.service_retriever.delete_task(task_uuid, max_retries)
|
||||
|
||||
|
||||
class ProcessCommentParserService:
|
||||
"""
|
||||
Class for processing comment parser tasks
|
||||
"""
|
||||
|
||||
instance = None
|
||||
REDIS_EXCEPTIONS = RedisHandler.REDIS_EXCEPTIONS
|
||||
|
||||
def __init__(self):
|
||||
if hasattr(self, '_initialized') and self._initialized:
|
||||
return
|
||||
self.service_retriever: ServiceTaskRetriever = ServiceTaskRetriever()
|
||||
self._initialized = True
|
||||
|
||||
def fetch_all_tasks(self) -> list[RedisTaskObject]:
|
||||
"""
|
||||
Get all tasks from Redis
|
||||
|
||||
Returns:
|
||||
list: List of task objects
|
||||
"""
|
||||
return self.service_retriever.fetch_all_tasks_parser()
|
||||
|
||||
def get_task_requirements(self) -> dict:
|
||||
"""
|
||||
Get task requirements from Redis
|
||||
Returns:
|
||||
dict: Task requirements if found
|
||||
"""
|
||||
if task_object := self.service_retriever.redis_handler.get(f'{ConfigServices.TASK_COMMENT_PARSER}'):
|
||||
return loads(task_object)
|
||||
return None
|
||||
|
||||
def set_task_requirements(self, task_object: RedisTaskObject):
|
||||
"""
|
||||
Set task requirements in Redis
|
||||
"""
|
||||
return self.service_retriever.redis_handler.set(f'{ConfigServices.TASK_COMMENT_PARSER}', dumps(task_object))
|
||||
|
||||
Reference in New Issue
Block a user