Skip to content

Commit

Permalink
Nick: disable auto rech for extract requests
Browse files Browse the repository at this point in the history
  • Loading branch information
nickscamara committed Jan 31, 2025
1 parent 6bfd24d commit e026917
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions apps/api/src/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ export async function getACUC(
let retries = 0;
const maxRetries = 5;

let isExtract = (mode === RateLimiterMode.Extract || mode === RateLimiterMode.ExtractStatus)
let rpcName =
mode === RateLimiterMode.Extract || mode === RateLimiterMode.ExtractStatus
isExtract
? "auth_credit_usage_chunk_extract"
: "auth_credit_usage_chunk_test_22_credit_pack_n_extract";
while (retries < maxRetries) {
Expand Down Expand Up @@ -132,7 +133,7 @@ export async function getACUC(
setCachedACUC(api_key, chunk);
}

return chunk;
return chunk ? { ...chunk, is_extract: isExtract } : null;
} else {
return null;
}
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/controllers/v1/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ export type AuthCreditUsageChunk = {
remaining_credits: number;
sub_user_id: string | null;
total_credits_sum: number;
is_extract?: boolean;
};

export interface RequestWithMaybeACUC<
Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/services/billing/credit_billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ export async function supaCheckTeamCredits(

if (
isAutoRechargeEnabled &&
chunk.remaining_credits < autoRechargeThreshold
chunk.remaining_credits < autoRechargeThreshold &&
!chunk.is_extract
) {
const autoChargeResult = await autoCharge(chunk, autoRechargeThreshold);
if (autoChargeResult.success) {
Expand Down

0 comments on commit e026917

Please sign in to comment.