mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 21:17:30 +00:00
Merge pull request #152 from kevinconan/main
fix: 继续修正会话窗口的计算问题,这回应该正确了
This commit is contained in:
@@ -931,7 +931,7 @@ class ClaudeAccountService {
|
|||||||
accountData.sessionWindowEnd = windowEnd.toISOString();
|
accountData.sessionWindowEnd = windowEnd.toISOString();
|
||||||
accountData.lastRequestTime = now.toISOString();
|
accountData.lastRequestTime = now.toISOString();
|
||||||
|
|
||||||
logger.info(`🕐 Created new session window for account ${accountData.name} (${accountId}): ${windowStart.toISOString()} - ${windowEnd.toISOString()}`);
|
logger.info(`🕐 Created new session window for account ${accountData.name} (${accountId}): ${windowStart.toISOString()} - ${windowEnd.toISOString()} (from current time)`);
|
||||||
|
|
||||||
return accountData;
|
return accountData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -942,11 +942,8 @@ class ClaudeAccountService {
|
|||||||
|
|
||||||
// 🕐 计算会话窗口开始时间
|
// 🕐 计算会话窗口开始时间
|
||||||
_calculateSessionWindowStart(requestTime) {
|
_calculateSessionWindowStart(requestTime) {
|
||||||
const hour = requestTime.getHours();
|
// 从当前时间开始创建窗口,只将分钟取整到整点
|
||||||
const windowStartHour = Math.floor(hour / 5) * 5; // 向下取整到最近的5小时边界
|
|
||||||
|
|
||||||
const windowStart = new Date(requestTime);
|
const windowStart = new Date(requestTime);
|
||||||
windowStart.setHours(windowStartHour);
|
|
||||||
windowStart.setMinutes(0);
|
windowStart.setMinutes(0);
|
||||||
windowStart.setSeconds(0);
|
windowStart.setSeconds(0);
|
||||||
windowStart.setMilliseconds(0);
|
windowStart.setMilliseconds(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user