This commit is contained in:
Timothy Jaeryang Baek
2026-06-29 13:03:14 -05:00
parent 7ea7680f56
commit 517cd8d102
45 changed files with 1293 additions and 969 deletions
+1 -5
View File
@@ -222,11 +222,7 @@ class FeedbackTable:
) -> FeedbackListResponse:
async with get_async_db_context(db) as db:
stmt = select(Feedback, User).join(User, Feedback.user_id == User.id)
count_stmt = (
select(func.count(Feedback.id))
.select_from(Feedback)
.join(User, Feedback.user_id == User.id)
)
count_stmt = select(func.count(Feedback.id)).select_from(Feedback).join(User, Feedback.user_id == User.id)
if filter:
# Apply model_id filter (exact match)
+3 -7
View File
@@ -144,9 +144,7 @@ class FolderTable:
except Exception:
return None
async def get_folder_by_id(
self, id: str, db: Optional[AsyncSession] = None
) -> Optional[FolderModel]:
async def get_folder_by_id(self, id: str, db: Optional[AsyncSession] = None) -> Optional[FolderModel]:
"""Fetch folder by ID only (no user_id filter). Used for shared access."""
try:
async with get_async_db_context(db) as db:
@@ -159,8 +157,7 @@ class FolderTable:
return None
async def get_shared_folder_ids_for_user(
self, user_id: str, user_group_ids: set[str],
db: Optional[AsyncSession] = None
self, user_id: str, user_group_ids: set[str], db: Optional[AsyncSession] = None
) -> dict[str, str]:
"""
Returns {folder_id: highest_permission} for all folders shared with user.
@@ -175,8 +172,7 @@ class FolderTable:
]
if user_group_ids:
conditions.append(
and_(AccessGrant.principal_type == 'group',
AccessGrant.principal_id.in_(user_group_ids))
and_(AccessGrant.principal_type == 'group', AccessGrant.principal_id.in_(user_group_ids))
)
result = await db.execute(
select(AccessGrant).filter(
+1 -5
View File
@@ -164,11 +164,7 @@ class FunctionsTable:
func_data['updated_at'] = int(time.time())
if func.id in existing_ids:
await db.execute(
update(Function)
.filter_by(id=func.id)
.values(**func_data)
)
await db.execute(update(Function).filter_by(id=func.id).values(**func_data))
else:
new_func = Function(**func_data)
db.add(new_func)
+9 -3
View File
@@ -210,7 +210,9 @@ class MemoriesTable:
)
db.add(memory)
await db.flush()
results.append({'action': action, 'status': 'created', 'memory': MemoryModel.model_validate(memory)})
results.append(
{'action': action, 'status': 'created', 'memory': MemoryModel.model_validate(memory)}
)
elif action == 'replace':
memory_id = operation.get('id')
@@ -228,7 +230,9 @@ class MemoriesTable:
memory.meta = {**(memory.meta or {}), **operation.get('meta')}
memory.updated_at = now
await db.flush()
results.append({'action': action, 'status': 'updated', 'memory': MemoryModel.model_validate(memory)})
results.append(
{'action': action, 'status': 'updated', 'memory': MemoryModel.model_validate(memory)}
)
elif action == 'move':
memory_id = operation.get('id')
@@ -241,7 +245,9 @@ class MemoriesTable:
memory.meta = {**(memory.meta or {}), **operation.get('meta')}
memory.updated_at = now
await db.flush()
results.append({'action': action, 'status': 'updated', 'memory': MemoryModel.model_validate(memory)})
results.append(
{'action': action, 'status': 'updated', 'memory': MemoryModel.model_validate(memory)}
)
elif action == 'remove':
memory_id = operation.get('id')
+1 -4
View File
@@ -540,10 +540,7 @@ class MessageTable:
)
grouped[mid][reaction.name]['count'] += 1
return {
mid: [Reactions(**r) for r in reactions.values()]
for mid, reactions in grouped.items()
}
return {mid: [Reactions(**r) for r in reactions.values()] for mid, reactions in grouped.items()}
async def get_thread_reply_counts_by_message_ids(
self, ids: list[str], db: Optional[AsyncSession] = None
+1 -3
View File
@@ -244,9 +244,7 @@ class ToolsTable:
try:
async with get_async_db_context(db) as db:
await db.execute(
update(Tool)
.filter_by(id=id)
.values(valves=encrypt_valves(valves), updated_at=int(time.time()))
update(Tool).filter_by(id=id).values(valves=encrypt_valves(valves), updated_at=int(time.time()))
)
await db.commit()
return await self.get_tool_by_id(id, db=db)