diff --git a/llmage/accounting.py b/llmage/accounting.py index e985e23..c3a0fd6 100644 --- a/llmage/accounting.py +++ b/llmage/accounting.py @@ -242,7 +242,6 @@ async def llm_accoung_failed(luid, reason=None): async def backup_accounted_llmusage(): """Backup yesterday's accounted records to history table and remove from llmusage.""" env = ServerEnv() - from datetime import datetime, timedelta yesterday = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d') ts = env.timestampstr() batched = 0 @@ -295,8 +294,7 @@ async def get_failed_accounting_records(filters=None, page=1, page_size=50): - start_date: filter use_date >= start_date - end_date: filter use_date <= end_date """ - env = ServerEnv() - async with get_sor_context(env, 'llmage') as sor: + async with get_sor_context(ServerEnv(), 'llmage') as sor: conditions = [] ns = {} if filters: diff --git a/wwwroot/api/llmusage_accounting_failed_update.dspy b/wwwroot/api/llmusage_accounting_failed_update.dspy index 3ce34a1..40b9ba5 100644 --- a/wwwroot/api/llmusage_accounting_failed_update.dspy +++ b/wwwroot/api/llmusage_accounting_failed_update.dspy @@ -1,6 +1,6 @@ #!/usr/bin/env python3 import json -from ahserver.serverenv import ServerEnv +from datetime import datetime result = {'success': False, 'message': ''} @@ -15,8 +15,7 @@ try: data['id'] = rid # Mark as handled - set handled_time if data.get('handled') == '1' and not data.get('handled_time'): - env = ServerEnv() - data['handled_time'] = env.timestampstr() + data['handled_time'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S') await sor.U('llmusage_accounting_failed', data) result['success'] = True result['message'] = '更新成功' diff --git a/wwwroot/api/llmusage_history_create.dspy b/wwwroot/api/llmusage_history_create.dspy new file mode 100644 index 0000000..3f307aa --- /dev/null +++ b/wwwroot/api/llmusage_history_create.dspy @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 +import json +result = {'success': False, 'message': '历史数据为只读,不可新增'} +return json.dumps(result, ensure_ascii=False, default=str) diff --git a/wwwroot/api/llmusage_history_delete.dspy b/wwwroot/api/llmusage_history_delete.dspy new file mode 100644 index 0000000..c2b4fc5 --- /dev/null +++ b/wwwroot/api/llmusage_history_delete.dspy @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 +import json +result = {'success': False, 'message': '历史数据为只读,不可删除'} +return json.dumps(result, ensure_ascii=False, default=str) diff --git a/wwwroot/api/llmusage_history_update.dspy b/wwwroot/api/llmusage_history_update.dspy new file mode 100644 index 0000000..e4578b0 --- /dev/null +++ b/wwwroot/api/llmusage_history_update.dspy @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 +import json +result = {'success': False, 'message': '历史数据为只读,不可修改'} +return json.dumps(result, ensure_ascii=False, default=str) diff --git a/wwwroot/failed_accounting.ui b/wwwroot/failed_accounting.ui index b4016a8..dabe5d0 100644 --- a/wwwroot/failed_accounting.ui +++ b/wwwroot/failed_accounting.ui @@ -27,7 +27,7 @@ "options": {"spacing": 4}, "subwidgets": [ {"widgettype": "Text", "options": {"text": "开始日期", "fontSize": "12px"}}, - {"widgettype": "DatePicker", "id": "start_date", "options": {"width": "150px"}} + {"widgettype": "TextInput", "id": "start_date", "options": {"width": "150px", "placeholder": "YYYY-MM-DD"}} ] }, { @@ -35,7 +35,7 @@ "options": {"spacing": 4}, "subwidgets": [ {"widgettype": "Text", "options": {"text": "结束日期", "fontSize": "12px"}}, - {"widgettype": "DatePicker", "id": "end_date", "options": {"width": "150px"}} + {"widgettype": "TextInput", "id": "end_date", "options": {"width": "150px", "placeholder": "YYYY-MM-DD"}} ] }, { @@ -66,7 +66,7 @@ "widgettype": "Button", "id": "search_btn", "options": { - "text": "查询", + "label": "查询", "bgcolor": "#1976d2", "color": "#ffffff", "width": "80px" diff --git a/wwwroot/index.ui b/wwwroot/index.ui index 4123f00..a2d8b90 100644 --- a/wwwroot/index.ui +++ b/wwwroot/index.ui @@ -24,7 +24,7 @@ { "widgettype": "VBox", "options": { - "backgroundColor": "#1e3a5f", + "bgcolor": "#1e3a5f", "padding": "24px", "cursor": "pointer", "borderRadius": "8px" @@ -71,7 +71,7 @@ { "widgettype": "VBox", "options": { - "backgroundColor": "#1e3a5f", + "bgcolor": "#1e3a5f", "padding": "24px", "cursor": "pointer", "borderRadius": "8px" @@ -118,7 +118,7 @@ { "widgettype": "VBox", "options": { - "backgroundColor": "#1e3a5f", + "bgcolor": "#1e3a5f", "padding": "24px", "cursor": "pointer", "borderRadius": "8px"