feat: Add max_files attribute to MinimalUserBrainEntity and BrainsUsers repository (#2229)

This pull request adds a new attribute, max_files, to the
MinimalUserBrainEntity class in the BrainsUsers repository. The
max_files attribute represents the maximum number of files allowed for a
brain integration.
This commit is contained in:
Stan Girard 2024-02-20 14:31:25 -08:00 committed by GitHub
parent 2a8014d3a2
commit 7212e62859
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -78,3 +78,4 @@ class MinimalUserBrainEntity(BaseModel):
brain_type: BrainType
description: str
integration_logo_url: str
max_files: int

View File

@ -36,7 +36,7 @@ class BrainsUsers(BrainsUsersInterface):
response = (
self.db.from_("brains_users")
.select(
"id:brain_id, rights, brains (brain_id, name, status, brain_type, description, meaning, integrations_user (brain_id, integration_id, integrations (id, integration_name, integration_logo_url)))"
"id:brain_id, rights, brains (brain_id, name, status, brain_type, description, meaning, integrations_user (brain_id, integration_id, integrations (id, integration_name, integration_logo_url, max_files)))"
)
.filter("user_id", "eq", user_id)
.execute()
@ -44,6 +44,7 @@ class BrainsUsers(BrainsUsersInterface):
user_brains: list[MinimalUserBrainEntity] = []
for item in response.data:
integration_logo_url = ""
max_files = 5000
if item["brains"]["brain_type"] == "integration":
if "integrations_user" in item["brains"]:
for integration_user in item["brains"]["integrations_user"]:
@ -51,6 +52,7 @@ class BrainsUsers(BrainsUsersInterface):
integration_logo_url = integration_user["integrations"][
"integration_logo_url"
]
max_files = integration_user["integrations"]["max_files"]
user_brains.append(
MinimalUserBrainEntity(
@ -65,6 +67,7 @@ class BrainsUsers(BrainsUsersInterface):
else ""
),
integration_logo_url=str(integration_logo_url),
max_files=max_files,
)
)
user_brains[-1].rights = item["rights"]
@ -99,6 +102,7 @@ class BrainsUsers(BrainsUsersInterface):
else ""
),
integration_logo_url="",
max_files=100,
)
def delete_brain_user_by_id(