fix(v1/crawl-status): fix stuck on 0 jobs

This commit is contained in:
Gergő Móricz 2025-01-15 18:51:39 +01:00
parent ce2f6ff884
commit dde3aebac4
2 changed files with 6 additions and 7 deletions

View File

@ -9,19 +9,17 @@ Authorization: Bearer {{$dotenv TEST_API_KEY}}
content-type: application/json content-type: application/json
{ {
"url":"https://opencorporates.com/companies/us_tn/001260776/" "url":"https://firecrawl.dev"
} }
### http://ibtikar.net.sa bugado. redirect
### https://bansko.bg/bg -> webhooks
### Crawl Website ### Crawl Website
# @name crawl # @name crawl
POST {{baseUrl}}/v1/map HTTP/1.1 POST {{baseUrl}}/v1/crawl HTTP/1.1
Authorization: Bearer {{$dotenv TEST_API_KEY}} Authorization: Bearer {{$dotenv TEST_API_KEY}}
content-type: application/json content-type: application/json
{ {
"url": "https://emelitastes.lausd.org" "url": "https://firecrawl.dev"
} }
### Check Crawl Status ### Check Crawl Status

View File

@ -12,6 +12,7 @@ import {
getDoneJobsOrdered, getDoneJobsOrdered,
getDoneJobsOrderedLength, getDoneJobsOrderedLength,
getThrottledJobs, getThrottledJobs,
isCrawlFinished,
} from "../../lib/crawl-redis"; } from "../../lib/crawl-redis";
import { getScrapeQueue } from "../../services/queue-service"; import { getScrapeQueue } from "../../services/queue-service";
import { import {
@ -116,7 +117,7 @@ export async function crawlStatusController(
sc.cancelled sc.cancelled
? "cancelled" ? "cancelled"
: validJobStatuses.every((x) => x[1] === "completed") && : validJobStatuses.every((x) => x[1] === "completed") &&
validJobStatuses.length > 0 await isCrawlFinished(req.params.jobId)
? "completed" ? "completed"
: "scraping"; : "scraping";