mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-15 15:15:55 +08:00
stupid
This commit is contained in:
parent
1a6e1134c4
commit
11f27fd7f8
@ -107,6 +107,7 @@ describe("Billing tests", () => {
|
||||
// crawl 1: regular fc.dev crawl (x credits)
|
||||
crawl({
|
||||
url: "https://firecrawl.dev",
|
||||
limit: 10,
|
||||
}),
|
||||
|
||||
// crawl 2: fc.dev crawl with json (5y credits)
|
||||
@ -123,7 +124,8 @@ describe("Billing tests", () => {
|
||||
required: ["four_word_summary"],
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
limit: 10,
|
||||
})
|
||||
]);
|
||||
|
||||
|
@ -10,16 +10,15 @@ export async function creditUsageController(
|
||||
): Promise<void> {
|
||||
try {
|
||||
// If we already have the credit usage info from auth, use it
|
||||
// TEMP: cache issues - mogery
|
||||
// if (req.acuc) {
|
||||
// res.json({
|
||||
// success: true,
|
||||
// data: {
|
||||
// remaining_credits: req.acuc.remaining_credits,
|
||||
// },
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
if (req.acuc) {
|
||||
res.json({
|
||||
success: true,
|
||||
data: {
|
||||
remaining_credits: req.acuc.remaining_credits,
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise fetch fresh data
|
||||
const chunk = await getACUCTeam(req.auth.team_id, false, false, RateLimiterMode.Scrape);
|
||||
|
@ -42,7 +42,7 @@ export async function scrapeController(
|
||||
});
|
||||
//
|
||||
|
||||
const isDirectToBullMQ = process.env.SEARCH_PREVIEW_TOKEN === req.body.__searchPreviewToken;
|
||||
const isDirectToBullMQ = process.env.SEARCH_PREVIEW_TOKEN !== undefined && process.env.SEARCH_PREVIEW_TOKEN === req.body.__searchPreviewToken;
|
||||
|
||||
await addScrapeJob(
|
||||
{
|
||||
|
@ -172,8 +172,7 @@ export async function searchController(
|
||||
};
|
||||
const startTime = new Date().getTime();
|
||||
const costTracking = new CostTracking();
|
||||
const isSearchPreview =
|
||||
process.env.SEARCH_PREVIEW_TOKEN === req.body.__searchPreviewToken;
|
||||
const isSearchPreview = process.env.SEARCH_PREVIEW_TOKEN !== undefined && process.env.SEARCH_PREVIEW_TOKEN === req.body.__searchPreviewToken;
|
||||
|
||||
try {
|
||||
req.body = searchRequestSchema.parse(req.body);
|
||||
|
@ -10,16 +10,15 @@ export async function tokenUsageController(
|
||||
): Promise<void> {
|
||||
try {
|
||||
// If we already have the token usage info from auth, use it
|
||||
// TEMP: cache issues - mogery
|
||||
// if (req.acuc) {
|
||||
// res.json({
|
||||
// success: true,
|
||||
// data: {
|
||||
// remaining_tokens: req.acuc.remaining_credits,
|
||||
// },
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
if (req.acuc) {
|
||||
res.json({
|
||||
success: true,
|
||||
data: {
|
||||
remaining_tokens: req.acuc.remaining_credits,
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise fetch fresh data
|
||||
const chunk = await getACUCTeam(req.auth.team_id, false, false, RateLimiterMode.Extract);
|
||||
|
@ -1049,6 +1049,15 @@ async function processKickoffJob(job: Job & { id: string }, token: string) {
|
||||
|
||||
async function billScrapeJob(job: Job & { id: string }, document: Document, logger: Logger, costTracking?: CostTracking) {
|
||||
let creditsToBeBilled: number | null = null;
|
||||
logger.warn("Billing scrape job", {
|
||||
jobId: job.id,
|
||||
teamId: job.data.team_id,
|
||||
creditsToBeBilled,
|
||||
is_scrape: job.data.is_scrape,
|
||||
bypassBilling: job.data.internalOptions?.bypassBilling,
|
||||
isTeamId: job.data.team_id === process.env.BACKGROUND_INDEX_TEAM_ID!,
|
||||
isDBAuthentication: process.env.USE_DB_AUTHENTICATION === "true",
|
||||
});
|
||||
|
||||
if (job.data.is_scrape !== true && !job.data.internalOptions?.bypassBilling) {
|
||||
creditsToBeBilled = await calculateCreditsToBeBilled(job.data.scrapeOptions, document, job.id, costTracking);
|
||||
|
Loading…
x
Reference in New Issue
Block a user