View Source Lightning.Invocation (Lightning v2.10.4)

The Invocation context.

Summary

Functions

Return all logs for a step as a string of text, separated by new line breaks

Returns an %Ecto.Changeset{} for tracking dataclip changes.

Returns an %Ecto.Changeset{} for tracking step changes.

Creates a dataclip.

Deletes a dataclip.

Exports work orders by performing a series of database operations wrapped in a transaction.

Gets a single dataclip given one of

Gets a single dataclip.

Query for retrieving the dataclip that was step's starting dataclip.

Query for retrieving the dataclip that was the result of a successful step.

Gets a single step.

Fetches a step and preloads the job via the step's event.

Returns the list of dataclips.

Returns the list of steps.

Return all logs for a step as a list

Searches for work orders based on project and search parameters.

Updates a dataclip.

Functions

Link to this function

assemble_logs_for_step(step)

View Source
@spec assemble_logs_for_step(Lightning.Invocation.Step.t()) :: binary()

Return all logs for a step as a string of text, separated by new line breaks

Link to this function

change_dataclip(dataclip, attrs \\ %{})

View Source

Returns an %Ecto.Changeset{} for tracking dataclip changes.

Examples

iex> change_dataclip(dataclip)
%Ecto.Changeset{data: %Dataclip{}}
Link to this function

change_step(step, attrs \\ %{})

View Source

Returns an %Ecto.Changeset{} for tracking step changes.

Examples

iex> change_step(step)
%Ecto.Changeset{data: %Step{}}
Link to this function

count_workorders(project, search_params)

View Source
Link to this function

create_dataclip(attrs \\ %{})

View Source
@spec create_dataclip(attrs :: map()) ::
  {:ok, Lightning.Invocation.Dataclip.t()}
  | {:error, Ecto.Changeset.t(Lightning.Invocation.Dataclip)}

Creates a dataclip.

Examples

iex> create_dataclip(%{field: value})
{:ok, %Dataclip{}}

iex> create_dataclip(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

delete_dataclip(dataclip)

View Source

Deletes a dataclip.

Examples

iex> delete_dataclip(dataclip)
{:ok, %Dataclip{}}

iex> delete_dataclip(dataclip)
{:error, %Ecto.Changeset{}}
Link to this function

export_workorders(project, user, search_params)

View Source

Exports work orders by performing a series of database operations wrapped in a transaction.

This function creates an audit log, a project file record, and enqueues an export job using a transaction. Each step is executed as part of an Ecto.Multi operation, ensuring atomicity.

Parameters

  • project - The project for which work orders are being exported. Expected to be a map or struct with an id field.
  • user - The user initiating the export operation. Expected to be a map or struct with an id field.
  • search_params - A map of search parameters used to filter work orders to export.

Returns

  • {:ok, %{audit: audit, project_file: project_file, export_job: job}} on success:

    • audit: The audit log entry created for the export operation.
    • project_file: The project file record created for the export operation.
    • export_job: The result of the export job enqueuing step.
  • {:error, step, reason, changes} if any step in the transaction fails:

    • step: The step where the error occurred, e.g., :audit, :project_file, or :export_job.
    • reason: The reason for the failure, typically an error atom.
    • changes: A map of changes up to the point of failure.
@spec get_dataclip(step_or_uuid :: Lightning.Invocation.Step.t() | Ecto.UUID.t()) ::
  Lightning.Invocation.Dataclip.t() | nil

Gets a single dataclip given one of:

  • a Dataclip uuid
  • a Step model

Returns nil if the Dataclip does not exist.

Examples

iex> get_dataclip("27b73932-16c7-4a72-86a3-85d805ccff98")
%Dataclip{}

iex> get_dataclip("27b73932-16c7-4a72-86a3-85d805ccff98")
nil

iex> get_dataclip(%Step{id: "a uuid"})
%Dataclip{}
@spec get_dataclip!(id :: Ecto.UUID.t()) :: Lightning.Invocation.Dataclip.t()

Gets a single dataclip.

Raises Ecto.NoResultsError if the Dataclip does not exist.

Examples

iex> get_dataclip!(123)
%Dataclip{}

iex> get_dataclip!(456)
** (Ecto.NoResultsError)
Link to this function

get_dataclip_details!(id)

View Source
@spec get_dataclip_details!(id :: Ecto.UUID.t()) :: Lightning.Invocation.Dataclip.t()
Link to this function

get_dataclip_for_run(run_id)

View Source
@spec get_dataclip_for_run(run_id :: Ecto.UUID.t()) ::
  Lightning.Invocation.Dataclip.t() | nil
Link to this function

get_dataclip_query(step)

View Source

Query for retrieving the dataclip that was step's starting dataclip.

Link to this function

get_first_dataclip_for_run_and_job(run_id, job_id)

View Source
@spec get_first_dataclip_for_run_and_job(
  run_id :: Ecto.UUID.t(),
  job_id :: Ecto.UUID.t()
) :: Lightning.Invocation.Dataclip.t() | nil
Link to this function

get_first_step_for_run_and_job(run_id, job_id)

View Source
@spec get_first_step_for_run_and_job(
  run_id :: Ecto.UUID.t(),
  job_id :: Ecto.UUID.t()
) :: Lightning.Invocation.Step.t() | nil
Link to this function

get_output_dataclip_query(step)

View Source

Query for retrieving the dataclip that was the result of a successful step.

@spec get_step!(Ecto.UUID.t()) :: Lightning.Invocation.Step.t()

Gets a single step.

Raises Ecto.NoResultsError if the Step does not exist.

Examples

iex> get_step!(123)
%Step{}

iex> get_step!(456)
** (Ecto.NoResultsError)
Link to this function

get_step_count_for_run(run_id)

View Source
@spec get_step_count_for_run(run_id :: Ecto.UUID.t()) :: non_neg_integer()

Fetches a step and preloads the job via the step's event.

Link to this function

get_workorders_by_ids(ids)

View Source
Link to this function

get_workorders_count_limit()

View Source
@spec list_dataclips() :: [Lightning.Invocation.Dataclip.t()]

Returns the list of dataclips.

Examples

iex> list_dataclips()
[%Dataclip{}, ...]
@spec list_dataclips(project :: Lightning.Projects.Project.t()) :: [
  Lightning.Invocation.Dataclip.t()
]
Link to this function

list_dataclips_for_job(job)

View Source
Link to this function

list_dataclips_query(project)

View Source
@spec list_dataclips_query(project :: Lightning.Projects.Project.t()) ::
  Ecto.Queryable.t()

Returns the list of steps.

Examples

iex> list_steps()
[%Step{}, ...]
Link to this function

list_steps_for_project(project, params \\ %{})

View Source
@spec list_steps_for_project(Lightning.Projects.Project.t(), keyword() | map()) ::
  Scrivener.Page.t()
Link to this function

list_steps_for_project_query(project)

View Source
@spec list_steps_for_project_query(Lightning.Projects.Project.t()) :: Ecto.Query.t()
@spec logs_for_step(Lightning.Invocation.Step.t()) :: list()

Return all logs for a step as a list

Link to this function

search_workorders(project)

View Source

Searches for work orders based on project and search parameters.

Parameters:

  • project: The project to filter the work orders by.
  • search_params: The parameters to guide the search.

Returns:

A paginated list of work orders that match the criteria.

Example:

search_workorders(%Project{id: 1}, %SearchParams{status: ["completed"]})
Link to this function

search_workorders(project, search_params, params \\ %{})

View Source
Link to this function

search_workorders_for_export_query(project, search_params)

View Source
Link to this function

search_workorders_for_retry(project, search_params)

View Source
Link to this function

update_dataclip(dataclip, attrs)

View Source

Updates a dataclip.

Examples

iex> update_dataclip(dataclip, %{field: new_value})
{:ok, %Dataclip{}}

iex> update_dataclip(dataclip, %{field: bad_value})
{:error, %Ecto.Changeset{}}