View Source Lightning.WorkOrders.ExportWorker (Lightning v2.10.4)

This module handles the export of work orders for a given project. The export process is performed asynchronously using the Oban background job system.

## Responsibilities

  • Enqueueing Export Jobs: The enqueue_export/2 function creates and enqueues an Oban job for exporting work orders based on the given project and search parameters.
  • Processing Exports: The perform/1 function is the main entry point for executing the export job. It retrieves the project, processes work orders, and handles the export process.
  • Export Logic: The export logic involves querying work orders, extracting relevant entities, processing logs and dataclips asynchronously, and writing the final export data to files.
  • Error Handling: The module includes comprehensive error handling and logging to ensure that issues during the export process are recorded and can be diagnosed.
  • Zip File Creation: After processing, the exported files are compressed into a zip file for easy download or further use.

## Usage

  • To enqueue an export job, call enqueue_export/2 with the project and search parameters.
  • The export process is triggered by Oban and runs in the history_exports queue, limited to a single attempt per job.

## Example

  # Enqueue an export job
  Lightning.WorkOrders.ExportWorker.enqueue_export(project, search_params)

  # The job will run in the background and log the status of the export process.

This module is designed to handle potentially large datasets efficiently by using streaming, async processing, and error recovery mechanisms.

Summary

Functions

Link to this function

enqueue_export(project, project_file, search_params)

View Source
Link to this function

extract_entities(work_order)

View Source
Link to this function

fetch_dataclips(dataclip_ids)

View Source