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:336–353  ·  view source on GitHub ↗

Get all organizations for a user with relationships preloaded.

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

Source from the content-addressed store, hash-verified

334
335 @classmethod
336 def get_all_for_user(cls, orm: orm.Session, user_id: str | UUID) -> Optional[list['OrgModel']]:
337 """Get all organizations for a user with relationships preloaded."""
338 orgs = (
339 orm.query(cls)
340 .options(
341 joinedload(cls.users),
342 joinedload(cls.invites),
343 joinedload(cls.projects),
344 )
345 .join(UserOrgModel, UserOrgModel.org_id == cls.id)
346 .filter(UserOrgModel.user_id == normalize_uuid(user_id))
347 .filter(cls.id != DEMO_ORG_ID) # TODO hard-code demo org and delete these rows
348 .all()
349 )
350 for org in orgs:
351 # populate current user so `org.current_user_role` is available
352 org.set_current_user(user_id)
353 return orgs
354
355 @classmethod
356 def get_all_for_user_summary(cls, orm: orm.Session, user_id: str | UUID) -> list['OrgModel']:

Callers 2

__call__Method · 0.45
get_user_orgsFunction · 0.45

Calls 3

set_current_userMethod · 0.80
normalize_uuidFunction · 0.70
filterMethod · 0.45

Tested by

no test coverage detected