搜索次数接口
This commit is contained in:
parent
3d35e7325e
commit
4194e9e12f
|
|
@ -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>
|
|
||||||
|
|
@ -14,7 +14,7 @@ from settings import TORTOISE_ORM
|
||||||
|
|
||||||
|
|
||||||
async def search_time_updates(redis: Redis) -> None:
|
async def search_time_updates(redis: Redis) -> None:
|
||||||
key = "search_times"
|
key = "search_time"
|
||||||
|
|
||||||
await redis.incr(key, 1)
|
await redis.incr(key, 1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@ async def get_search_time(request: Request):
|
||||||
|
|
||||||
key = f"search_time"
|
key = f"search_time"
|
||||||
|
|
||||||
count = int(await redis.get(key))
|
count = await redis.get(key)
|
||||||
if not count:
|
if not count:
|
||||||
await redis.set(key, value=0)
|
await redis.set(key, value=0)
|
||||||
count = 0
|
count = 0
|
||||||
print(count)
|
print(count, type(count))
|
||||||
return {
|
return {
|
||||||
"count": count,
|
"count": int(count),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
main.py
4
main.py
|
|
@ -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.api.word_comment.routes import word_comment_router
|
||||||
from app.core.redis import init_redis, close_redis
|
from app.core.redis import init_redis, close_redis
|
||||||
from app.utils.phone_encrypt import PhoneEncrypt
|
from app.utils.phone_encrypt import PhoneEncrypt
|
||||||
from settings import ONLINE_SETTINGS
|
from settings import TORTOISE_ORM
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
|
|
@ -47,7 +47,7 @@ app.add_middleware(
|
||||||
|
|
||||||
register_tortoise(
|
register_tortoise(
|
||||||
app=app,
|
app=app,
|
||||||
config=ONLINE_SETTINGS,
|
config=TORTOISE_ORM
|
||||||
)
|
)
|
||||||
|
|
||||||
app.include_router(users_router, tags=["User API"], prefix="/users")
|
app.include_router(users_router, tags=["User API"], prefix="/users")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue