added failed and completed log events

This commit is contained in:
rafaelsideguide 2024-07-24 15:25:36 -03:00
parent 60c74357df
commit cc98f83fda
2 changed files with 4 additions and 1 deletions

View File

@ -25,7 +25,7 @@ export type ScrapeScrapeEvent = {
export type ScrapeQueueEvent = { export type ScrapeQueueEvent = {
type: "queue", type: "queue",
event: "waiting" | "active" | "completed" | "paused" | "resumed" | "removed", event: "waiting" | "active" | "completed" | "paused" | "resumed" | "removed" | "failed",
worker?: string, worker?: string,
} }

View File

@ -11,6 +11,7 @@ import { billTeam } from "../services/billing/credit_billing";
import { Document } from "../lib/entities"; import { Document } from "../lib/entities";
import { supabase_service } from "../services/supabase"; import { supabase_service } from "../services/supabase";
import { Logger } from "../lib/logger"; import { Logger } from "../lib/logger";
import { ScrapeEvents } from "../lib/scrape-events";
export async function startWebScraperPipeline({ export async function startWebScraperPipeline({
job, job,
@ -39,6 +40,7 @@ export async function startWebScraperPipeline({
}, },
onError: (error) => { onError: (error) => {
Logger.error(`🐂 Job failed ${job.id}`); Logger.error(`🐂 Job failed ${job.id}`);
ScrapeEvents.logJobEvent(job, "failed");
job.moveToFailed(error); job.moveToFailed(error);
}, },
team_id: job.data.team_id, team_id: job.data.team_id,
@ -140,6 +142,7 @@ const saveJob = async (job: Job, result: any) => {
// I think the job won't exist here anymore // I think the job won't exist here anymore
} }
} }
ScrapeEvents.logJobEvent(job, "completed");
} catch (error) { } catch (error) {
Logger.error(`🐂 Failed to update job status: ${error}`); Logger.error(`🐂 Failed to update job status: ${error}`);
} }