From 7212e628593f8c04afab4c0486730b96a9ee8498 Mon Sep 17 00:00:00 2001 From: Stan Girard Date: Tue, 20 Feb 2024 14:31:25 -0800 Subject: [PATCH] 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. --- backend/modules/brain/entity/brain_entity.py | 1 + backend/modules/brain/repository/brains_users.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/modules/brain/entity/brain_entity.py b/backend/modules/brain/entity/brain_entity.py index 1f7a36995..996a4abe9 100644 --- a/backend/modules/brain/entity/brain_entity.py +++ b/backend/modules/brain/entity/brain_entity.py @@ -78,3 +78,4 @@ class MinimalUserBrainEntity(BaseModel): brain_type: BrainType description: str integration_logo_url: str + max_files: int diff --git a/backend/modules/brain/repository/brains_users.py b/backend/modules/brain/repository/brains_users.py index 20be77d61..299f88a6f 100644 --- a/backend/modules/brain/repository/brains_users.py +++ b/backend/modules/brain/repository/brains_users.py @@ -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(