From cec5266655ac86ebfe2c93189b430e0d7d1b7f83 Mon Sep 17 00:00:00 2001 From: Jeremy Yin Date: Fri, 15 Mar 2024 22:42:53 +0800 Subject: [PATCH] change to get --- simplylab/main.py | 10 +++++----- simplylab/services/chat.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/simplylab/main.py b/simplylab/main.py index 9a4478b..4018e6d 100644 --- a/simplylab/main.py +++ b/simplylab/main.py @@ -95,13 +95,13 @@ async def get_user_chat_history(request: Request, req: GetUserChatHistoryInput) return res -@app.post("/api/v1/get_chat_status_today") -async def get_chat_status_today(request: Request, req: GetChatStatusTodayInput) -> GetChatStatusTodayOutput: +@app.get("/api/v1/get_chat_status_today") +async def get_chat_status_today(request: Request, user_name: str) -> GetChatStatusTodayOutput: pvd = Providers(db=request.app.db) - user = await pvd.user.get_user_by_name(req.user_name) + user = await pvd.user.get_user_by_name(user_name) if not user: - raise UserNotFoundError(req.user_name) + raise UserNotFoundError(user_name) ctx = Context(user=user) svc = Services(ctx, pvd) - res = await svc.chat.get_chat_status_today(req) + res = await svc.chat.get_chat_status_today() return res diff --git a/simplylab/services/chat.py b/simplylab/services/chat.py index 09ed604..5e06ea5 100644 --- a/simplylab/services/chat.py +++ b/simplylab/services/chat.py @@ -47,7 +47,7 @@ class ChatService: res.append(UserChatMessage(type=message.type.value, text=message.text)) return res - async def get_chat_status_today(self, req: GetChatStatusTodayInput) -> GetChatStatusTodayOutput: + async def get_chat_status_today(self) -> GetChatStatusTodayOutput: count = await self.pvd.chat.get_user_chat_messages_count_today(user_id=self.ctx.user.id) res = GetChatStatusTodayOutput(user_name=self.ctx.user.name, chat_cnt=count) return res