Fix MiniMax percentage calculation (API returns remaining, not used)
This commit is contained in:
4
dist/index.js
vendored
4
dist/index.js
vendored
@@ -123,9 +123,11 @@ async function getMinimaxUsage() {
|
|||||||
const used = m.current_interval_usage_count;
|
const used = m.current_interval_usage_count;
|
||||||
const total = m.current_interval_total_count;
|
const total = m.current_interval_total_count;
|
||||||
const pct = (used / total) * 100;
|
const pct = (used / total) * 100;
|
||||||
|
const isRemainingPct = pct > 50;
|
||||||
|
const finalPct = isRemainingPct ? 100 - pct : pct;
|
||||||
const totalMinutes = remainingMinutes / (1 - used/total) || 0;
|
const totalMinutes = remainingMinutes / (1 - used/total) || 0;
|
||||||
|
|
||||||
return { pct, remainingMinutes, totalMinutes, model: m.model_name, error: null };
|
return { pct: finalPct, remainingMinutes, totalMinutes, model: m.model_name, error: null };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return { pct: 0, remainingMinutes: 0, totalMinutes: 0, model: '?', error: e.message };
|
return { pct: 0, remainingMinutes: 0, totalMinutes: 0, model: '?', error: e.message };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user