From 0b33b1418b47a58e84c61ff2202e7108e4d1712c Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 12 Aug 2025 16:48:22 +0800 Subject: [PATCH] bugfix --- rag/ragprogram.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/rag/ragprogram.py b/rag/ragprogram.py index 2c730a6..9a19af4 100644 --- a/rag/ragprogram.py +++ b/rag/ragprogram.py @@ -1,19 +1,16 @@ -from appPublic.timeUtils import curDateString, dateadd +from appPublic.timeUtils import curDateString, dateAdd from ahserver.serverenv import get_serverenv -async def set_program(request, program_type, quota): +async def set_program(request, program_type, quota, term=1): db = DBPools() dbname = get_serverenv('get_module_dbname')('rag') async with db.sqlorContext(dbname) as sor: u = await get_session_userinfo(request) sql="select * from ragquote where orgid = ${orgid}$ order by enabled_date" qs = await sor.sqlExe(sql, {'orgid': u.userorgid}) - today = curDateString() if len(qs) == 0: - if params_kw.program_type == 'free': - expired_date = dateadd(today, months=1) - else: - expired_date = '9999-12-31' + today = curDateString() + expired_date = dateadd(today, months=term) ns = { "id": uuid(), "orgid": u.userorgid, @@ -24,12 +21,11 @@ async def set_program(request, program_type, quota): await sor.C('ragquota', ns) else: lastq = qs[-1] - lastq.expired_date = today - await sor.U('ragquote', lastq.copy()) + expired_date = dateadd(lastq.expired_date, months=term) ns = { "id": uuid(), "orgid": u.userorgid, - "enabled_date": today, + "enabled_date": lastq.expired_date, "expired_date": expired_date, 'quota': params_kw.quota }