Skip to content

Commit 1b3aec7

Browse files
committed
Revert "wip: zen"
This reverts commit b302472.
1 parent b302472 commit 1b3aec7

2 files changed

Lines changed: 0 additions & 165 deletions

File tree

packages/console/core/script/batch-onboard.ts

Lines changed: 0 additions & 91 deletions
This file was deleted.

packages/console/core/script/lookup-user.ts

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -254,80 +254,6 @@ function getSubscriptionStatus(row: {
254254
}
255255
}
256256

257-
function formatMicroCents(value: number | null | undefined) {
258-
if (value === null || value === undefined) return null
259-
return `$${(value / 100000000).toFixed(2)}`
260-
}
261-
262-
function formatDate(value: Date | null | undefined) {
263-
if (!value) return null
264-
return value.toISOString().split("T")[0]
265-
}
266-
267-
function formatMonthlyUsage(usage: number | null | undefined, limit: number | null | undefined) {
268-
const usageText = formatMicroCents(usage) ?? "$0.00"
269-
if (limit === null || limit === undefined) return `${usageText} / no limit`
270-
return `${usageText} / $${limit.toFixed(2)}`
271-
}
272-
273-
function formatRetryTime(seconds: number) {
274-
const days = Math.floor(seconds / 86400)
275-
if (days >= 1) return `${days} day${days > 1 ? "s" : ""}`
276-
const hours = Math.floor(seconds / 3600)
277-
const minutes = Math.ceil((seconds % 3600) / 60)
278-
if (hours >= 1) return `${hours}hr ${minutes}min`
279-
return `${minutes}min`
280-
}
281-
282-
function getSubscriptionStatus(row: {
283-
timeSubscriptionCreated: Date | null
284-
fixedUsage: number | null
285-
rollingUsage: number | null
286-
timeFixedUpdated: Date | null
287-
timeRollingUpdated: Date | null
288-
}) {
289-
if (!row.timeSubscriptionCreated) {
290-
return { weekly: null, rolling: null, rateLimited: null, retryIn: null }
291-
}
292-
293-
const black = BlackData.get()
294-
const now = new Date()
295-
const week = getWeekBounds(now)
296-
297-
const fixedLimit = black.fixedLimit ? centsToMicroCents(black.fixedLimit * 100) : null
298-
const rollingLimit = black.rollingLimit ? centsToMicroCents(black.rollingLimit * 100) : null
299-
const rollingWindowMs = (black.rollingWindow ?? 5) * 3600 * 1000
300-
301-
// Calculate current weekly usage (reset if outside current week)
302-
const currentWeekly =
303-
row.fixedUsage && row.timeFixedUpdated && row.timeFixedUpdated >= week.start ? row.fixedUsage : 0
304-
305-
// Calculate current rolling usage
306-
const windowStart = new Date(now.getTime() - rollingWindowMs)
307-
const currentRolling =
308-
row.rollingUsage && row.timeRollingUpdated && row.timeRollingUpdated >= windowStart ? row.rollingUsage : 0
309-
310-
// Check rate limiting
311-
const isWeeklyLimited = fixedLimit !== null && currentWeekly >= fixedLimit
312-
const isRollingLimited = rollingLimit !== null && currentRolling >= rollingLimit
313-
314-
let retryIn: string | null = null
315-
if (isWeeklyLimited) {
316-
const retryAfter = Math.ceil((week.end.getTime() - now.getTime()) / 1000)
317-
retryIn = formatRetryTime(retryAfter)
318-
} else if (isRollingLimited && row.timeRollingUpdated) {
319-
const retryAfter = Math.ceil((row.timeRollingUpdated.getTime() + rollingWindowMs - now.getTime()) / 1000)
320-
retryIn = formatRetryTime(retryAfter)
321-
}
322-
323-
return {
324-
weekly: fixedLimit !== null ? `${formatMicroCents(currentWeekly)} / $${black.fixedLimit}` : null,
325-
rolling: rollingLimit !== null ? `${formatMicroCents(currentRolling)} / $${black.rollingLimit}` : null,
326-
rateLimited: isWeeklyLimited || isRollingLimited ? "yes" : "no",
327-
retryIn,
328-
}
329-
}
330-
331257
function printHeader(title: string) {
332258
console.log()
333259
console.log("─".repeat(title.length))

0 commit comments

Comments
 (0)