refac
This commit is contained in:
1 parent
601bb78358
commit
968462609f
2 files changed
+16
-2
No files matched your search
@@ -176,6 +176,11 @@ class GroupTable:
|
|||||||
groups = db.query(Group).order_by(Group.updated_at.desc()).all()
|
groups = db.query(Group).order_by(Group.updated_at.desc()).all()
|
||||||
return [GroupModel.model_validate(group) for group in groups]
|
return [GroupModel.model_validate(group) for group in groups]
|
||||||
|
|
||||||
|
def get_group_by_name(self, name: str, db: Optional[Session] = None) -> Optional[GroupModel]:
|
||||||
|
with get_db_context(db) as db:
|
||||||
|
group = db.query(Group).filter(Group.name == name).first()
|
||||||
|
return GroupModel.model_validate(group) if group else None
|
||||||
|
|
||||||
def get_groups(self, filter, db: Optional[Session] = None) -> list[GroupResponse]:
|
def get_groups(self, filter, db: Optional[Session] = None) -> list[GroupResponse]:
|
||||||
with get_db_context(db) as db:
|
with get_db_context(db) as db:
|
||||||
member_count = (
|
member_count = (
|
||||||
|
|||||||
@@ -790,8 +790,17 @@ async def get_groups(
|
|||||||
startIndex = max(1, startIndex)
|
startIndex = max(1, startIndex)
|
||||||
count = max(0, min(100, count))
|
count = max(0, min(100, count))
|
||||||
|
|
||||||
# Get all groups
|
# Get groups, applying filter if provided
|
||||||
groups_list = Groups.get_all_groups(db=db)
|
if filter:
|
||||||
|
if 'displayName eq' in filter:
|
||||||
|
display_name = filter.split('"')[1]
|
||||||
|
group = Groups.get_group_by_name(display_name, db=db)
|
||||||
|
groups_list = [group] if group else []
|
||||||
|
else:
|
||||||
|
# Unrecognized filter — fall back to all groups
|
||||||
|
groups_list = Groups.get_all_groups(db=db)
|
||||||
|
else:
|
||||||
|
groups_list = Groups.get_all_groups(db=db)
|
||||||
|
|
||||||
# Apply pagination
|
# Apply pagination
|
||||||
total = len(groups_list)
|
total = len(groups_list)
|
||||||
|
|||||||
Reference in new issue
Block a user