From 3d133a26eae5498062fd5a1b9e1256cc1f449f1d Mon Sep 17 00:00:00 2001 From: abhijeet Date: Thu, 31 Aug 2023 20:00:45 +0530 Subject: [PATCH 1/2] Updated pool size --- main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index a2cbf7f08..c9db03d43 100644 --- a/main.py +++ b/main.py @@ -74,8 +74,13 @@ else: db_url = f'postgresql://{db_username}:{db_password}@{database_url}/{db_name}' -engine = create_engine(db_url) -# SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) +engine = create_engine(db_url, + pool_size=20, # Maximum number of database connections in the pool + max_overflow=50, # Maximum number of connections that can be created beyond the pool_size + pool_timeout=30, # Timeout value in seconds for acquiring a connection from the pool + pool_recycle=1800, # Recycle connections after this number of seconds (optional) + pool_pre_ping=False, # Enable connection health checks (optional) + ) # app.add_middleware(DBSessionMiddleware, db_url=f'postgresql://{db_username}:{db_password}@localhost/{db_name}') app.add_middleware(DBSessionMiddleware, db_url=db_url) From 247fefa62c0b927580451385df91c8f01e06d82b Mon Sep 17 00:00:00 2001 From: abhijeet Date: Thu, 31 Aug 2023 22:40:34 +0530 Subject: [PATCH 2/2] Call logs organistaion level fix --- superagi/apm/call_log_helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/superagi/apm/call_log_helper.py b/superagi/apm/call_log_helper.py index 8bc8c8460..85d359d4e 100644 --- a/superagi/apm/call_log_helper.py +++ b/superagi/apm/call_log_helper.py @@ -37,7 +37,7 @@ def fetch_data(self, model: str): func.sum(CallLogs.tokens_consumed), func.count(CallLogs.id), func.count(distinct(CallLogs.agent_id)) - ).filter(CallLogs.model == model).first() + ).filter(CallLogs.model == model, CallLogs.org_id == self.organisation_id).first() if result is None: return None @@ -51,7 +51,7 @@ def fetch_data(self, model: str): } # Fetch all runs for this model - runs = self.session.query(CallLogs).filter(CallLogs.model == model).all() + runs = self.session.query(CallLogs).filter(CallLogs.model == model, CallLogs.org_id == self.organisation_id).all() for run in runs: # Get agent's name using agent_id as a foreign key agent = self.session.query(Agent).filter(Agent.id == run.agent_id).first()