MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / get_all_for_user

Method get_all_for_user

app/api/agentops/opsboard/models.py:673–696  ·  view source on GitHub ↗

Get all projects the user has access to across all organizations they belong to.

(cls, orm: orm.Session, user_id: str | UUID)

Source from the content-addressed store, hash-verified

671
672 @classmethod
673 def get_all_for_user(cls, orm: orm.Session, user_id: str | UUID) -> list['ProjectModel']:
674 """Get all projects the user has access to across all organizations they belong to."""
675 projects = (
676 orm.query(cls)
677 .join(OrgModel, cls.org_id == OrgModel.id)
678 .join(
679 UserOrgModel,
680 UserOrgModel.org_id == OrgModel.id,
681 )
682 .filter(UserOrgModel.user_id == normalize_uuid(user_id))
683 .filter(OrgModel.id != DEMO_ORG_ID) # TODO hard-code demo org and delete these rows
684 .options(
685 joinedload(cls.org).joinedload(OrgModel.users),
686 joinedload(cls.org).joinedload(OrgModel.invites),
687 joinedload(cls.org).joinedload(OrgModel.projects),
688 )
689 .all()
690 )
691
692 # Set the current user for each project's org
693 for project in projects:
694 project.org.set_current_user(user_id)
695
696 return projects
697
698 @classmethod
699 def get_all_for_user_optimized(cls, orm: orm.Session, user_id: str | UUID) -> list['ProjectModel']:

Callers

nothing calls this directly

Calls 3

set_current_userMethod · 0.80
normalize_uuidFunction · 0.70
filterMethod · 0.45

Tested by

no test coverage detected