web / lib/jobs/workflows/review-checks
lib/jobs/workflows/review-checks
Review check functions for the ingest pipeline.
These checks run between pipeline tasks and can pause processing by setting the IngestJob to NEEDS_REVIEW with a specific reason. The user (or admin) reviews the issue and decides how to proceed.
Variables
REVIEW_REASONS
constREVIEW_REASONS:object
Review reasons — extensible enum for different pause conditions.
Type Declaration
SCHEMA_DRIFT
readonlySCHEMA_DRIFT:"schema-drift"="schema-drift"
QUOTA_EXCEEDED
readonlyQUOTA_EXCEEDED:"quota-exceeded"="quota-exceeded"
HIGH_DUPLICATE_RATE
readonlyHIGH_DUPLICATE_RATE:"high-duplicates"="high-duplicates"
GEOCODING_PARTIAL
readonlyGEOCODING_PARTIAL:"geocoding-partial"="geocoding-partial"
REVIEW_RESUME_POINTS
constREVIEW_RESUME_POINTS:Record<string,string>
Maps review reason → resume point for the ingest-process workflow.
Functions
setNeedsReview()
setNeedsReview(
payload,ingestJobId,reason,details):Promise<void>
Set an IngestJob to NEEDS_REVIEW with a specific reason and details.
Parameters
payload
BasePayload
ingestJobId
string | number
reason
string
details
Record<string, unknown>
Returns
Promise<void>
checkQuotaForSheet()
checkQuotaForSheet(
payload,ingestJobId,uniqueRows):Promise<{ allowed: boolean; current?: number; limit?: number; estimatedNew?: number; reason?: string; }>
Check if importing uniqueRows events would exceed the user’s quota.
Returns { allowed: true } or { allowed: false, ...details }.
Parameters
payload
BasePayload
ingestJobId
string | number
uniqueRows
number
Returns
Promise<{ allowed: boolean; current?: number; limit?: number; estimatedNew?: number; reason?: string; }>
shouldReviewHighDuplicates()
shouldReviewHighDuplicates(
totalRows,uniqueRows):object
Check if the duplicate rate is too high (>80% by default). Returns true if review is needed.
Parameters
totalRows
number
uniqueRows
number
Returns
object
needsReview
needsReview:
boolean
duplicateRate?
optionalduplicateRate?:number
shouldReviewGeocodingPartial()
shouldReviewGeocodingPartial(
geocoded,failed):object
Check if geocoding had too many failures (>50% by default). Returns true if review is needed.
Parameters
geocoded
number
failed
number
Returns
object
needsReview
needsReview:
boolean
failRate?
optionalfailRate?:number
getResumePointForReason()
getResumePointForReason(
reason):string
Get the resume point for a given review reason.
Parameters
reason
string | null | undefined
Returns
string