-
Notifications
You must be signed in to change notification settings - Fork 71
refactor: consolidate run and work order state definitions #4600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,8 @@ defmodule Lightning.Run do | |
| :final_dataclip_id | ||
| ]} | ||
|
|
||
| @active_states [:available, :claimed, :started] | ||
|
|
||
| @final_states [ | ||
| :success, | ||
| :failed, | ||
|
|
@@ -56,6 +58,13 @@ defmodule Lightning.Run do | |
| """ | ||
| def final_states, do: @final_states | ||
|
|
||
| @doc """ | ||
| Returns the list of active (in-progress) states for a run. | ||
|
|
||
| These are all non-final states: available, claimed, and started. | ||
| """ | ||
| def active_states, do: @active_states | ||
|
|
||
|
Comment on lines
+61
to
+67
|
||
| @doc """ | ||
| Returns the list of failure states for a run. | ||
|
|
||
|
|
@@ -98,15 +107,7 @@ defmodule Lightning.Run do | |
| embeds_one :options, Lightning.Runs.RunOptions | ||
|
|
||
| field :state, Ecto.Enum, | ||
| values: | ||
| Enum.concat( | ||
| [ | ||
| :available, | ||
| :claimed, | ||
| :started | ||
| ], | ||
| @final_states | ||
| ), | ||
| values: Enum.concat(@active_states, @final_states), | ||
| default: :available | ||
|
|
||
| field :error_type, :string | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_last_failed_workorder/2later in this module still hardcodes[:pending, :running, :success]asexcluded_states, which conflicts with the PR goal of removing hardcoded work order state lists fromlib/. Consider deriving this list fromWorkOrder.active_states()(or@wo_active) to keep a single source of truth.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Now deriving excluded_states from
@wo_active ++ [:success], which matches the pattern already used inbatch_get_last_workorderson line 65.