From 856d6e7d85fb3bb1eae010e340a7b6665e036ad2 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Thu, 26 Feb 2026 10:48:18 +0100 Subject: [PATCH 1/4] perf: microsoft copilot in cognition --- models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/models.py b/models.py index 07e22393..1b0de3d0 100644 --- a/models.py +++ b/models.py @@ -1255,6 +1255,7 @@ class CognitionProject(Base): icon = Column(String, default="IconBolt") allow_conversation_sharing_organization = Column(Boolean, default=False) allow_conversation_sharing_global = Column(Boolean, default=False) + allow_microsoft_copilot_connection = Column(Boolean, default=False) class CognitionStrategy(Base): From 1678ef237668304ec4ead830087bce171883ba65 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Thu, 26 Feb 2026 10:56:03 +0100 Subject: [PATCH 2/4] perf: add allow_microsoft_copilot_connection to cognition project --- cognition_objects/project.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cognition_objects/project.py b/cognition_objects/project.py index da3f4e28..9b50afd9 100644 --- a/cognition_objects/project.py +++ b/cognition_objects/project.py @@ -223,6 +223,7 @@ def update( icon: Optional[str] = None, allow_conversation_sharing_organization: Optional[bool] = None, allow_conversation_sharing_global: Optional[bool] = None, + allow_microsoft_copilot_connection: Optional[bool] = None, with_commit: bool = True, ) -> CognitionProject: project: CognitionProject = get(project_id) @@ -282,6 +283,8 @@ def update( ) if allow_conversation_sharing_global is not None: project.allow_conversation_sharing_global = allow_conversation_sharing_global + if allow_microsoft_copilot_connection is not None: + project.allow_microsoft_copilot_connection = allow_microsoft_copilot_connection general.flush_or_commit(with_commit) return project From f652fc6b21209e2dddfcb3ab17b2ad6f040e60f4 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Wed, 4 Mar 2026 20:20:16 +0100 Subject: [PATCH 3/4] perf: filter copilot projects --- cognition_objects/project.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cognition_objects/project.py b/cognition_objects/project.py index 9b50afd9..fb795d8a 100644 --- a/cognition_objects/project.py +++ b/cognition_objects/project.py @@ -75,6 +75,21 @@ def get_all(org_id: str, order_by_name: bool = False) -> List[CognitionProject]: return query.all() +def get_all_allowed_copilot( + org_id: str, order_by_name: bool = False +) -> List[CognitionProject]: + query = session.query(CognitionProject).filter( + CognitionProject.organization_id == org_id, + CognitionProject.allow_microsoft_copilot_connection is True, + ) + + if order_by_name: + query = query.order_by(CognitionProject.name.asc()) + else: + query = query.order_by(CognitionProject.created_at.asc()) + return query.all() + + def get_all_all() -> List[CognitionProject]: return session.query(CognitionProject).all() @@ -107,6 +122,16 @@ def get_all_by_user(org_id: str, user_id: str) -> List[CognitionProject]: ) +def get_all_by_user_allowed_copilot( + org_id: str, user_id: str +) -> List[CognitionProject]: + user_item = user.get(user_id) + if user_item.role == enums.UserRoles.ENGINEER.value: + return get_all_allowed_copilot(org_id) + + raise PermissionError("ERROR: Unauthorized") + + # returns a dict with ENGINEERING_TEAM as key for all users that are not annotators def get_project_users_overview( organization_id: str, project_id: Optional[str] = None From a4d8ca0b71de899d83c52a8fa8ce510057500622 Mon Sep 17 00:00:00 2001 From: andhreljaKern Date: Thu, 5 Mar 2026 14:23:04 +0100 Subject: [PATCH 4/4] perf: add copilot allowed filter --- cognition_objects/project.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cognition_objects/project.py b/cognition_objects/project.py index fb795d8a..e98f3efc 100644 --- a/cognition_objects/project.py +++ b/cognition_objects/project.py @@ -7,6 +7,7 @@ from datetime import datetime from ..util import prevent_sql_injection from sqlalchemy.orm.attributes import flag_modified +from sqlalchemy.sql.expression import true from copy import deepcopy from ..db_cache import TTLCacheDecorator, CacheEnum @@ -78,9 +79,10 @@ def get_all(org_id: str, order_by_name: bool = False) -> List[CognitionProject]: def get_all_allowed_copilot( org_id: str, order_by_name: bool = False ) -> List[CognitionProject]: - query = session.query(CognitionProject).filter( - CognitionProject.organization_id == org_id, - CognitionProject.allow_microsoft_copilot_connection is True, + query = ( + session.query(CognitionProject) + .filter(CognitionProject.organization_id == org_id) + .filter(CognitionProject.allow_microsoft_copilot_connection == true()) ) if order_by_name: