fix(api): playground scrape errors

This commit is contained in:
Gergő Móricz 2024-09-26 22:28:14 +02:00
parent 8d44cb33bb
commit e98f858eb6
4 changed files with 4 additions and 4 deletions

View File

@ -244,7 +244,7 @@ export async function scrapeController(req: Request, res: Response) {
}
if (creditsToBeBilled > 0) {
// billing for doc done on queue end, bill only for llm extraction
billTeam(team_id, chunk.sub_id, creditsToBeBilled).catch(error => {
billTeam(team_id, chunk?.sub_id, creditsToBeBilled).catch(error => {
Logger.error(`Failed to bill team ${team_id} for ${creditsToBeBilled} credits: ${error}`);
// Optionally, you could notify an admin or add to a retry queue here
});

View File

@ -170,7 +170,7 @@ export async function searchController(req: Request, res: Response) {
jobId,
req,
team_id,
chunk.sub_id,
chunk?.sub_id,
crawlerOptions,
pageOptions,
searchOptions,

View File

@ -152,7 +152,7 @@ export async function mapController(
// remove duplicates that could be due to http/https or www
links = removeDuplicateUrls(links);
billTeam(req.auth.team_id, req.acuc.sub_id, 1).catch((error) => {
billTeam(req.auth.team_id, req.acuc?.sub_id, 1).catch((error) => {
Logger.error(
`Failed to bill team ${req.auth.team_id} for 1 credit: ${error}`
);

View File

@ -108,7 +108,7 @@ export async function scrapeController(
creditsToBeBilled = 5;
}
billTeam(req.auth.team_id, req.acuc.sub_id, creditsToBeBilled).catch(error => {
billTeam(req.auth.team_id, req.acuc?.sub_id, creditsToBeBilled).catch(error => {
Logger.error(`Failed to bill team ${req.auth.team_id} for ${creditsToBeBilled} credits: ${error}`);
// Optionally, you could notify an admin or add to a retry queue here
});