nsfw mark api

This commit is contained in:
xds
2026-02-27 09:08:48 +03:00
parent e976fe1c58
commit e4a39e90c3
4 changed files with 45 additions and 3 deletions

View File

@@ -131,6 +131,16 @@ class GenerationRepo:
)
return True
async def mark_nsfw(self, generation_id: str, is_nsfw: bool) -> bool:
if not ObjectId.is_valid(generation_id):
return False
res = await self.collection.update_one(
{"_id": ObjectId(generation_id)},
{"$set": {"nsfw": is_nsfw}}
)
return res.modified_count > 0
async def get_usage_stats(self, created_by: Optional[str] = None, project_id: Optional[str] = None) -> dict:
"""
Calculates usage statistics (runs, tokens, cost) using MongoDB aggregation.