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

Method get_by_id

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

Get a project by ID with org and necessary relationships preloaded.

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

Source from the content-addressed store, hash-verified

635
636 @classmethod
637 def get_by_id(cls, orm: orm.Session, project_id: str | UUID) -> Optional['ProjectModel']:
638 """Get a project by ID with org and necessary relationships preloaded."""
639 # This loads org.users, org.invites, and org.projects relationships which are
640 # needed when returning a `ProjectResponse` in these view functions:
641 # - get_project
642 # - create_project
643 # - update_project
644 # - regenerate_api_key
645 # TODO: Consider optimizing with count queries instead of loading full relationships
646 # when we only need counts for org.current_member_count and org.current_project_count.
647 return (
648 orm.query(cls)
649 .filter(cls.id == normalize_uuid(project_id))
650 .options(
651 joinedload(cls.org).joinedload(OrgModel.users),
652 joinedload(cls.org).joinedload(OrgModel.invites),
653 joinedload(cls.org).joinedload(OrgModel.projects),
654 )
655 .first()
656 )
657
658 @classmethod
659 def get_by_api_key(cls, orm: orm.Session, api_key: str | UUID) -> Optional['ProjectModel']:

Callers

nothing calls this directly

Calls 2

normalize_uuidFunction · 0.70
filterMethod · 0.45

Tested by

no test coverage detected