web / lib/jobs/utils/event-creation-helpers
lib/jobs/utils/event-creation-helpers
Helper utilities for creating events from imported data.
Provides functions for extracting coordinates, timestamps, and creating event data structures during the import process.
Functions
extractCoordinates()
extractCoordinates(
row,fieldMappings,geocodingResults):object
Extract coordinates from a row based on field mappings and geocoding results. Priority: import coordinates from data > geocoded location > none
Parameters
row
Record<string, unknown>
fieldMappings
latitudePath?
string | null
longitudePath?
string | null
locationPath?
string | null
geocodingResults
Returns
object
location?
optionallocation:object
location.latitude
latitude:
number
location.longitude
longitude:
number
coordinateSource
coordinateSource:
object
coordinateSource.type
type:
"none"|"import"|"geocoded"
coordinateSource.confidence?
optionalconfidence:number
coordinateSource.normalizedAddress?
optionalnormalizedAddress:string
extractTimestamp()
extractTimestamp(
row,timestampPath?):Date|null
Extract timestamp from row data using field mapping.
Parameters
row
Record<string, unknown>
timestampPath?
string | null
Returns
Date | null
createEventData()
createEventData(
row,dataset,importJobId,job,geocodingResults,transformationChanges):object
Create event data structure from a row of imported data.
Parameters
row
Record<string, unknown>
dataset
Dataset
importJobId
string | number
job
datasetSchemaVersion?
unknown
detectedFieldMappings?
{ latitudePath?: string \| null; longitudePath?: string \| null; locationPath?: string \| null; locationNamePath?: string \| null; timestampPath?: string \| null; }
detectedFieldMappings.latitudePath?
string | null
detectedFieldMappings.longitudePath?
string | null
detectedFieldMappings.locationPath?
string | null
detectedFieldMappings.locationNamePath?
string | null
detectedFieldMappings.timestampPath?
string | null
geocodingResults
transformationChanges
object[] | null
Returns
object
dataset
dataset:
number=dataset.id
importJob
importJob:
number|undefined
data
data:
Record<string,unknown> =row
uniqueId
uniqueId:
string
eventTimestamp
eventTimestamp:
string
location
location:
{ latitude: number; longitude: number; }|undefined
locationName
locationName:
string|null
coordinateSource
coordinateSource:
object
coordinateSource.type
type:
"none"|"import"|"geocoded"
coordinateSource.confidence?
optionalconfidence:number
coordinateSource.normalizedAddress?
optionalnormalizedAddress:string
validationStatus
validationStatus:
"pending"|"transformed"
transformations
transformations:
object[] |null=transformationChanges
schemaVersionNumber
schemaVersionNumber:
number|undefined=schemaVersion