mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-12 15:39:03 +08:00
Merge branch 'main' into v1-webscraper
This commit is contained in:
commit
88239d7211
@ -317,21 +317,21 @@ export async function supaCheckTeamCredits(team_id: string, credits: number) {
|
||||
|
||||
// Compare the adjusted total credits used with the credits allowed by the plan
|
||||
if (adjustedCreditsUsed + credits > price.credits) {
|
||||
await sendNotification(
|
||||
team_id,
|
||||
NotificationType.LIMIT_REACHED,
|
||||
subscription.current_period_start,
|
||||
subscription.current_period_end
|
||||
);
|
||||
// await sendNotification(
|
||||
// team_id,
|
||||
// NotificationType.LIMIT_REACHED,
|
||||
// subscription.current_period_start,
|
||||
// subscription.current_period_end
|
||||
// );
|
||||
return { success: false, message: "Insufficient credits, please upgrade!", remainingCredits: creditLimit - adjustedCreditsUsed };
|
||||
} else if (creditUsagePercentage >= 0.8) {
|
||||
// Send email notification for approaching credit limit
|
||||
await sendNotification(
|
||||
team_id,
|
||||
NotificationType.APPROACHING_LIMIT,
|
||||
subscription.current_period_start,
|
||||
subscription.current_period_end
|
||||
);
|
||||
// await sendNotification(
|
||||
// team_id,
|
||||
// NotificationType.APPROACHING_LIMIT,
|
||||
// subscription.current_period_start,
|
||||
// subscription.current_period_end
|
||||
// );
|
||||
}
|
||||
|
||||
return { success: true, message: "Sufficient credits available", remainingCredits: creditLimit - adjustedCreditsUsed };
|
||||
|
@ -65,7 +65,7 @@ describe("Rate Limiter Service", () => {
|
||||
"test-prefix:someToken",
|
||||
"standard"
|
||||
);
|
||||
expect(limiter2.points).toBe(50);
|
||||
expect(limiter2.points).toBe(100);
|
||||
|
||||
const limiter3 = getRateLimiter(
|
||||
"search" as RateLimiterMode,
|
||||
@ -188,14 +188,13 @@ describe("Rate Limiter Service", () => {
|
||||
"test-prefix:someTokenXY",
|
||||
"hobby"
|
||||
);
|
||||
// expect hobby to have 100 points
|
||||
expect(limiter.points).toBe(10);
|
||||
expect(limiter.points).toBe(20);
|
||||
|
||||
const consumePoints = 5;
|
||||
|
||||
const res = await limiter.consume("test-prefix:someTokenXY", consumePoints);
|
||||
expect(res.consumedPoints).toBe(5);
|
||||
expect(res.remainingPoints).toBe(5);
|
||||
expect(res.remainingPoints).toBe(15);
|
||||
});
|
||||
|
||||
it("should return the correct rate limiter for 'crawl' mode", () => {
|
||||
@ -227,7 +226,7 @@ describe("Rate Limiter Service", () => {
|
||||
"test-prefix:someToken",
|
||||
"free"
|
||||
);
|
||||
expect(limiter.points).toBe(5);
|
||||
expect(limiter.points).toBe(10);
|
||||
|
||||
const limiter2 = getRateLimiter(
|
||||
"scrape" as RateLimiterMode,
|
||||
@ -241,7 +240,14 @@ describe("Rate Limiter Service", () => {
|
||||
"test-prefix:someToken",
|
||||
"standard"
|
||||
);
|
||||
expect(limiter3.points).toBe(50);
|
||||
expect(limiter3.points).toBe(100);
|
||||
|
||||
const limiter4 = getRateLimiter(
|
||||
"scrape" as RateLimiterMode,
|
||||
"test-prefix:someToken",
|
||||
"growth"
|
||||
);
|
||||
expect(limiter4.points).toBe(1000);
|
||||
});
|
||||
|
||||
it("should return the correct rate limiter for 'search' mode", () => {
|
||||
|
@ -18,12 +18,12 @@ const RATE_LIMITS = {
|
||||
},
|
||||
scrape: {
|
||||
default: 20,
|
||||
free: 5,
|
||||
free: 10,
|
||||
starter: 20,
|
||||
standard: 100,
|
||||
standardOld: 40,
|
||||
scale: 500,
|
||||
hobby: 10,
|
||||
hobby: 20,
|
||||
standardNew: 100,
|
||||
standardnew: 100,
|
||||
growth: 1000,
|
||||
@ -115,7 +115,7 @@ export function getRateLimiter(
|
||||
return testSuiteRateLimiter;
|
||||
}
|
||||
|
||||
if(teamId === process.env.DEV_B_TEAM_ID) {
|
||||
if(teamId && teamId === process.env.DEV_B_TEAM_ID) {
|
||||
return devBRateLimiter;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user