+ Add thread info

+ Remove N/A from web view when result is empty
This commit is contained in:
Wong Yiek Heng 2025-10-05 09:15:58 +08:00
parent 3b71b87887
commit 42b86a78d2
2 changed files with 19 additions and 18 deletions

View File

@ -1,8 +1,8 @@
from cm_bot_hal import CM_BOT_HAL
import logging, time, requests, json
import logging, time, requests, json, os, threading
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime
import os
from cm_bot_hal import CM_BOT_HAL
# Suppress httpx logs
logging.getLogger("httpx").setLevel(logging.WARNING)
@ -14,16 +14,17 @@ if not os.path.exists(logs_dir):
# api_url = 'https://api.luckytown888.net'
api_url = 'http://api-server:3000'
max_threading = 1
max_threading = 5
def transfer(data: dict, local_logger):
bot = CM_BOT_HAL()
local_logger.info(f"[Start] Transfer Credit from {data['f_username']} to {data['t_username']}")
thread_name = threading.current_thread().name
local_logger.info(f"[Thread-{thread_name}] [Start] Transfer Credit from {data['f_username']} to {data['t_username']}")
result = bot.transfer_credit_api(data['f_username'], data['f_password'], data['t_username'], data['t_password'])
local_logger.info(result)
local_logger.info(f"[Done] {data['f_username']} transfer done!")
local_logger.info(f"[Thread-{thread_name}] {result}")
local_logger.info(f"[Thread-{thread_name}] [Done] {data['f_username']} transfer done!")
del bot
time.sleep(0.5)
time.sleep(1)
while True:
weekday = int(datetime.now().strftime("%w"))
@ -54,4 +55,4 @@ while True:
with ThreadPoolExecutor(max_workers=max_threading) as executor:
results = list(executor.map(lambda item: transfer(item, local_logger), items))
local_logger.info(f"Completed processing {total_items} transfer items.")
time.sleep(1)
time.sleep(5 * 60)

View File

@ -457,17 +457,17 @@ HTML_TEMPLATE = """
<tbody>
${sortedData.map((acc, index) => `
<tr>
<td><strong>${acc.username || 'N/A'}</strong></td>
<td><strong>${acc.username}</strong></td>
<td class="editable" onclick="startEdit(this, 'password', 'acc', ${accData.findIndex(a => a.username === acc.username)})">
${acc.password || 'N/A'}
${acc.password || ''}
</td>
<td class="editable" onclick="startEdit(this, 'status', 'acc', ${accData.findIndex(a => a.username === acc.username)})">
<span class="status-badge ${acc.status === 'active' ? 'status-active' : 'status-inactive'}">
${acc.status || 'N/A'}
${acc.status || ''}
</span>
</td>
<td class="editable" onclick="startEdit(this, 'link', 'acc', ${accData.findIndex(a => a.username === acc.username)})">
${acc.link || 'N/A'}
${acc.link || ''}
</td>
</tr>
`).join('')}
@ -505,17 +505,17 @@ HTML_TEMPLATE = """
<tbody>
${sortedData.map((user, index) => `
<tr>
<td><strong>${user.f_username || 'N/A'}</strong></td>
<td><strong>${user.f_username}</strong></td>
<td class="editable" onclick="startEdit(this, 'f_password', 'user', ${userData.findIndex(u => u.f_username === user.f_username)})">
${user.f_password || 'N/A'}
${user.f_password || ''}
</td>
<td class="editable" onclick="startEdit(this, 't_username', 'user', ${userData.findIndex(u => u.f_username === user.f_username)})">
<strong>${user.t_username || 'N/A'}</strong>
<strong>${user.t_username || ''}</strong>
</td>
<td class="editable" onclick="startEdit(this, 't_password', 'user', ${userData.findIndex(u => u.f_username === user.f_username)})">
${user.t_password || 'N/A'}
${user.t_password || ''}
</td>
<td>${user.last_update_time || 'N/A'}</td>
<td>${user.last_update_time || 'No record'}</td>
</tr>
`).join('')}
</tbody>