搜索次数接口

This commit is contained in:
Miyamizu-MitsuhaSang 2025-11-06 20:02:34 +08:00
parent 3d35e7325e
commit 4194e9e12f
4 changed files with 6 additions and 16 deletions

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SqlDialectMappings">
<file url="file://$PROJECT_DIR$/migrations/models/11_20250803092810_update.py" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/migrations/models/16_20250806104900_update.py" dialect="GenericSQL" />
<file url="file://$PROJECT_DIR$/migrations/models/21_20250827100315_update.py" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/migrations/models/33_20250929111212_update.py" dialect="MySQL" />
<file url="file://$PROJECT_DIR$/scripts/update_fr.py" dialect="MySQL" />
</component>
</project>

View File

@ -14,7 +14,7 @@ from settings import TORTOISE_ORM
async def search_time_updates(redis: Redis) -> None:
key = "search_times"
key = "search_time"
await redis.incr(key, 1)

View File

@ -10,11 +10,11 @@ async def get_search_time(request: Request):
key = f"search_time"
count = int(await redis.get(key))
count = await redis.get(key)
if not count:
await redis.set(key, value=0)
count = 0
print(count)
print(count, type(count))
return {
"count": count,
"count": int(count),
}

View File

@ -19,7 +19,7 @@ from app.api.util_api.routes import ulit_router
from app.api.word_comment.routes import word_comment_router
from app.core.redis import init_redis, close_redis
from app.utils.phone_encrypt import PhoneEncrypt
from settings import ONLINE_SETTINGS
from settings import TORTOISE_ORM
@asynccontextmanager
@ -47,7 +47,7 @@ app.add_middleware(
register_tortoise(
app=app,
config=ONLINE_SETTINGS,
config=TORTOISE_ORM
)
app.include_router(users_router, tags=["User API"], prefix="/users")