From 017a915ae8f550ceaa01ad607b4e6a684385eadf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20M=C3=B3ricz?= Date: Thu, 8 May 2025 18:34:13 +0200 Subject: [PATCH] Revert "fix(queue-worker, scrape): match billing logic and add billing for stealth proxies (#1521)" This reverts commit e06c7cc234b9ee0c4bf112cc338e515f28674e11. --- apps/api/src/controllers/v1/scrape.ts | 4 ---- apps/api/src/services/queue-worker.ts | 15 +++------------ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/apps/api/src/controllers/v1/scrape.ts b/apps/api/src/controllers/v1/scrape.ts index d492156f..d052431b 100644 --- a/apps/api/src/controllers/v1/scrape.ts +++ b/apps/api/src/controllers/v1/scrape.ts @@ -155,10 +155,6 @@ export async function scrapeController( } } - if (req.body.proxy === "stealth") { - creditsToBeBilled += 4; - } - billTeam(req.auth.team_id, req.acuc?.sub_id, creditsToBeBilled).catch( (error) => { logger.error( diff --git a/apps/api/src/services/queue-worker.ts b/apps/api/src/services/queue-worker.ts index 4747110c..4e56394c 100644 --- a/apps/api/src/services/queue-worker.ts +++ b/apps/api/src/services/queue-worker.ts @@ -1331,20 +1331,11 @@ async function processJob(job: Job & { id: string }, token: string) { if (job.data.is_scrape !== true) { let creditsToBeBilled = 1; // Assuming 1 credit per document - if ((job.data.scrapeOptions.extract && job.data.scrapeOptions.formats?.includes("extract")) || (job.data.scrapeOptions.formats?.includes("changeTracking") && job.data.scrapeOptions.changeTrackingOptions?.modes?.includes("json"))) { + if (job.data.scrapeOptions.extract) { creditsToBeBilled = 5; } - - if (job.data.scrapeOptions.agent?.model?.toLowerCase() === "fire-1" || job.data.scrapeOptions.extract?.agent?.model?.toLowerCase() === "fire-1" || job.data.scrapeOptions.jsonOptions?.agent?.model?.toLowerCase() === "fire-1") { - if (process.env.USE_DB_AUTHENTICATION === "true") { - creditsToBeBilled = Math.ceil((costTracking.toJSON().totalCost ?? 1) * 1800); - } else { - creditsToBeBilled = 150; - } - } - - if (job.data.scrapeOptions.proxy === "stealth") { - creditsToBeBilled += 4; + if (job.data.scrapeOptions.agent?.model?.toLowerCase() === "fire-1") { + creditsToBeBilled = 150; } if (