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