mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-02 08:40:53 +03:00
feat: Add integration_logo_url to MinimalUserBrainEntity (#2225)
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
This commit is contained in:
parent
0ec9eb00b8
commit
6db67cc7b6
@ -77,3 +77,4 @@ class MinimalUserBrainEntity(BaseModel):
|
||||
status: str
|
||||
brain_type: BrainType
|
||||
description: str
|
||||
integration_logo_url: str
|
||||
|
@ -36,13 +36,27 @@ class BrainsUsers(BrainsUsersInterface):
|
||||
response = (
|
||||
self.db.from_("brains_users")
|
||||
.select(
|
||||
"id:brain_id, rights, brains (brain_id, name, status, brain_type, description, meaning)"
|
||||
"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)))"
|
||||
)
|
||||
.filter("user_id", "eq", user_id)
|
||||
.execute()
|
||||
)
|
||||
user_brains: list[MinimalUserBrainEntity] = []
|
||||
for item in response.data:
|
||||
integration_logo_url = ""
|
||||
if item["brains"]["brain_type"] == "integration":
|
||||
logger.info("Integration brain")
|
||||
logger.info(item["brains"])
|
||||
if "integrations_user" in item["brains"]:
|
||||
for integration_user in item["brains"]["integrations_user"]:
|
||||
if "integrations" in integration_user:
|
||||
integration_logo_url = integration_user["integrations"][
|
||||
"integration_logo_url"
|
||||
]
|
||||
logger.info(
|
||||
"Integration logo url: " + str(integration_logo_url)
|
||||
)
|
||||
|
||||
user_brains.append(
|
||||
MinimalUserBrainEntity(
|
||||
id=item["brains"]["brain_id"],
|
||||
@ -50,9 +64,12 @@ class BrainsUsers(BrainsUsersInterface):
|
||||
rights=item["rights"],
|
||||
status=item["brains"]["status"],
|
||||
brain_type=item["brains"]["brain_type"],
|
||||
description=item["brains"]["description"]
|
||||
if item["brains"]["description"] is not None
|
||||
else "",
|
||||
description=(
|
||||
item["brains"]["description"]
|
||||
if item["brains"]["description"] is not None
|
||||
else ""
|
||||
),
|
||||
integration_logo_url=str(integration_logo_url),
|
||||
)
|
||||
)
|
||||
user_brains[-1].rights = item["rights"]
|
||||
@ -81,9 +98,11 @@ class BrainsUsers(BrainsUsersInterface):
|
||||
rights=brain_data["rights"],
|
||||
status=brain_data["brains"]["status"],
|
||||
brain_type=brain_data["brains"]["brain_type"],
|
||||
description=brain_data["brains"]["description"]
|
||||
if brain_data["brains"]["description"] is not None
|
||||
else "",
|
||||
description=(
|
||||
brain_data["brains"]["description"]
|
||||
if brain_data["brains"]["description"] is not None
|
||||
else ""
|
||||
),
|
||||
)
|
||||
|
||||
def delete_brain_user_by_id(
|
||||
|
Loading…
Reference in New Issue
Block a user