This commit is contained in:
SunSeekerX
2026-01-04 12:05:53 +08:00
parent 90023d1551
commit f5e982632d
28 changed files with 481 additions and 213 deletions

View File

@@ -94,7 +94,9 @@ class CostInitService {
}
}
logger.info(`💰 Found ${apiKeyIds.length} active API Keys to process (filtered ${allKeyIds.length - apiKeyIds.length} deleted)`)
logger.info(
`💰 Found ${apiKeyIds.length} active API Keys to process (filtered ${allKeyIds.length - apiKeyIds.length} deleted)`
)
let processedCount = 0
let errorCount = 0
@@ -155,7 +157,9 @@ class CostInitService {
for (let j = 0; j < results.length; j++) {
const [err, values] = results[j]
if (err) continue
if (err) {
continue
}
// 将数组转换为对象
const data = {}
@@ -182,7 +186,9 @@ class CostInitService {
const match = key.match(
/usage:(.+):model:(daily|monthly|hourly):(.+):(\d{4}-\d{2}(?:-\d{2})?(?::\d{2})?)$/
)
if (!match) continue
if (!match) {
continue
}
const [, , period, model, dateStr] = match
@@ -301,7 +307,9 @@ class CostInitService {
cursor = newCursor
for (const usageKey of usageKeys) {
if (samplesChecked >= maxSamples) break
if (samplesChecked >= maxSamples) {
break
}
const match = usageKey.match(/usage:(.+):model:daily:(.+):(\d{4}-\d{2}-\d{2})$/)
if (match) {
@@ -319,7 +327,9 @@ class CostInitService {
}
}
if (samplesChecked >= maxSamples) break
if (samplesChecked >= maxSamples) {
break
}
} while (cursor !== '0')
logger.info('💰 Cost data appears to be up to date')