Skip to content

Commit e026917

Browse files
committed
Nick: disable auto rech for extract requests
1 parent 6bfd24d commit e026917

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

apps/api/src/controllers/auth.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ export async function getACUC(
9494
let retries = 0;
9595
const maxRetries = 5;
9696

97+
let isExtract = (mode === RateLimiterMode.Extract || mode === RateLimiterMode.ExtractStatus)
9798
let rpcName =
98-
mode === RateLimiterMode.Extract || mode === RateLimiterMode.ExtractStatus
99+
isExtract
99100
? "auth_credit_usage_chunk_extract"
100101
: "auth_credit_usage_chunk_test_22_credit_pack_n_extract";
101102
while (retries < maxRetries) {
@@ -132,7 +133,7 @@ export async function getACUC(
132133
setCachedACUC(api_key, chunk);
133134
}
134135

135-
return chunk;
136+
return chunk ? { ...chunk, is_extract: isExtract } : null;
136137
} else {
137138
return null;
138139
}

apps/api/src/controllers/v1/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ export type AuthCreditUsageChunk = {
655655
remaining_credits: number;
656656
sub_user_id: string | null;
657657
total_credits_sum: number;
658+
is_extract?: boolean;
658659
};
659660

660661
export interface RequestWithMaybeACUC<

apps/api/src/services/billing/credit_billing.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ export async function supaCheckTeamCredits(
150150

151151
if (
152152
isAutoRechargeEnabled &&
153-
chunk.remaining_credits < autoRechargeThreshold
153+
chunk.remaining_credits < autoRechargeThreshold &&
154+
!chunk.is_extract
154155
) {
155156
const autoChargeResult = await autoCharge(chunk, autoRechargeThreshold);
156157
if (autoChargeResult.success) {

0 commit comments

Comments
 (0)