Lightning.Invocation.Query (Lightning v2.20.1)

Copy Markdown View Source

Query functions for working with Steps and Dataclips

Summary

Functions

By default, the dataclip body is not returned via a query. This query selects the body specifically.

Narrows a query of log lines by filters, keyed and typed as log_line_filter_types/0 says.

Narrows a query of runs by filters, keyed and typed as run_filter_types/0 says.

Narrows a query of work orders by filters, keyed and typed as work_order_filter_types/0 says.

The last step for a job

The last successful step for a job, used in scheduler to enable downstream runs to access a previous run's state

The filters filter_log_lines/2 takes, each with its type.

Log lines of every project the caller may list (Lightning.Projects.visible_project_ids/1).

The filters filter_runs/2 takes, each with its type.

Runs of a given project, or of every project the caller may list (Lightning.Projects.visible_project_ids/1).

Returns a dataclip formatted for use as an input state.

Dataclips a job can be run against: the ones it has consumed, plus every named dataclip in its project.

Steps for a specific user

The last step for a job for a particular exit reason, used in scheduler

Appends exit_reason != "success" to a query of Step.

The filters filter_work_orders/2 takes, each with its type.

Work orders of a given project, or of every project the caller may list (Lightning.Projects.visible_project_ids/1).

Functions

dataclip_with_body()

By default, the dataclip body is not returned via a query. This query selects the body specifically.

filter_log_lines(query, filters)

@spec filter_log_lines(Ecto.Queryable.t(), map()) :: Ecto.Queryable.t()

Narrows a query of log lines by filters, keyed and typed as log_line_filter_types/0 says.

filter_runs(query, filters)

@spec filter_runs(Ecto.Queryable.t(), map()) :: Ecto.Queryable.t()

Narrows a query of runs by filters, keyed and typed as run_filter_types/0 says.

filter_work_orders(query, filters)

@spec filter_work_orders(Ecto.Queryable.t(), map()) :: Ecto.Queryable.t()

Narrows a query of work orders by filters, keyed and typed as work_order_filter_types/0 says.

last_n_for_job(job_id, limit)

last_step_for_job(job)

@spec last_step_for_job(Lightning.Workflows.Job.t()) :: Ecto.Queryable.t()

The last step for a job

last_successful_step_for_job(job)

@spec last_successful_step_for_job(Lightning.Workflows.Job.t()) :: Ecto.Queryable.t()

The last successful step for a job, used in scheduler to enable downstream runs to access a previous run's state

log_line_filter_types()

@spec log_line_filter_types() :: %{required(atom()) => Ecto.Type.t()}

The filters filter_log_lines/2 takes, each with its type.

log_lines_for(scope)

@spec log_lines_for(Lightning.Scope.t()) :: Ecto.Queryable.t()
@spec log_lines_for(Lightning.Projects.Project.t()) :: Ecto.Queryable.t()

Log lines of every project the caller may list (Lightning.Projects.visible_project_ids/1).

order_by_run_recency(query)

@spec order_by_run_recency(Ecto.Queryable.t()) :: Ecto.Queryable.t()

run_filter_types()

@spec run_filter_types() :: %{required(atom()) => Ecto.Type.t()}

The filters filter_runs/2 takes, each with its type.

runs_for(scope)

Runs of a given project, or of every project the caller may list (Lightning.Projects.visible_project_ids/1).

select_as_input_text(query)

Returns a dataclip formatted for use as an input state.

Only http_request dataclips are changed, their body is nested inside a "data" key and request data is added as a "request" key.

Like select_as_input/1, but returns body as JSON text string to avoid expensive deserialization to Elixir map (saves ~38x memory amplification).

selectable_for_job(job_id, project_id, limit)

Dataclips a job can be run against: the ones it has consumed, plus every named dataclip in its project.

A named dataclip is a curated input rather than a trace of a past run, so the result is no longer bounded by the job. The two sources are unioned rather than ORed so each keeps its own index, instead of making dataclips the driving relation on every keystroke of the picker's search.

steps_for(user)

Steps for a specific user

steps_with_reason(query, exit_reason)

@spec steps_with_reason(Ecto.Queryable.t(), String.t()) :: Ecto.Queryable.t()

The last step for a job for a particular exit reason, used in scheduler

where_step_failed(query)

@spec where_step_failed(Ecto.Queryable.t()) :: Ecto.Queryable.t()

Appends exit_reason != "success" to a query of Step.

A step that never finished carries a nil exit_reason, and NULL != 'success' is false in SQL, so it is excluded here too: a step still in flight is not yet a failure.

wipe_dataclips(query \\ Dataclip)

work_order_filter_types()

@spec work_order_filter_types() :: %{required(atom()) => Ecto.Type.t()}

The filters filter_work_orders/2 takes, each with its type.

work_orders_for(scope)

@spec work_orders_for(Lightning.Scope.t()) :: Ecto.Queryable.t()
@spec work_orders_for(Lightning.Projects.Project.t()) :: Ecto.Queryable.t()

Work orders of a given project, or of every project the caller may list (Lightning.Projects.visible_project_ids/1).