This commit is contained in:
Timothy Jaeryang Baek
2026-07-17 04:11:11 -04:00
parent a213355785
commit 56f2cb5302
3 changed files with 31 additions and 2 deletions
+20 -1
View File
@@ -259,7 +259,26 @@ class SkillsTable:
permission='read',
)
stmt = stmt.order_by(Skill.updated_at.desc())
order_by = filter.get('order_by')
direction = filter.get('direction')
if order_by == 'name':
if direction == 'asc':
stmt = stmt.order_by(Skill.name.asc())
else:
stmt = stmt.order_by(Skill.name.desc())
elif order_by == 'created_at':
if direction == 'asc':
stmt = stmt.order_by(Skill.created_at.asc())
else:
stmt = stmt.order_by(Skill.created_at.desc())
elif order_by == 'updated_at':
if direction == 'asc':
stmt = stmt.order_by(Skill.updated_at.asc())
else:
stmt = stmt.order_by(Skill.updated_at.desc())
else:
stmt = stmt.order_by(Skill.updated_at.desc())
# Count BEFORE pagination
count_result = await db.execute(select(func.count()).select_from(stmt.subquery()))
+6
View File
@@ -72,6 +72,8 @@ async def get_skills(
async def get_skill_list(
query: Optional[str] = None,
view_option: Optional[str] = None,
order_by: Optional[str] = None,
direction: Optional[str] = None,
page: Optional[int] = 1,
user=Depends(get_verified_user),
db: AsyncSession = Depends(get_async_session),
@@ -86,6 +88,10 @@ async def get_skill_list(
filter['query'] = query
if view_option:
filter['view_option'] = view_option
if order_by:
filter['order_by'] = order_by
if direction:
filter['direction'] = direction
if not (user.role == 'admin' and BYPASS_ADMIN_ACCESS_CONTROL):
groups = await Groups.get_groups_by_member_id(user.id, db=db)
+5 -1
View File
@@ -97,7 +97,9 @@ export const getSkillItems = async (
token: string = '',
query: string | null = null,
viewOption: string | null = null,
page: number | null = null
page: number | null = null,
orderBy: string | null = null,
direction: string | null = null
) => {
let error = null;
@@ -105,6 +107,8 @@ export const getSkillItems = async (
if (query) searchParams.append('query', query);
if (viewOption) searchParams.append('view_option', viewOption);
if (page) searchParams.append('page', page.toString());
if (orderBy) searchParams.append('order_by', orderBy);
if (direction) searchParams.append('direction', direction);
const res = await fetch(`${WEBUI_API_BASE_URL}/skills/list?${searchParams.toString()}`, {
method: 'GET',