This PR doesn't simply set display_state as "deleting" at "destroy" label because our operations are async. When user clicked "delete" button, web service increases "destroy" semaphore, and respirate moves nexus to destroy label. Until respirate fetches strand and run, state isn't changed. In addition, destroying vm is quick, so probably vm's disappeared when user reload page again. To fix this delayed display_state issue, I override method to decide display state for some special semaphores. In this PR, if "destroy" semaphore is increased, vm.display_state returns "deleting" immediately. I added `one_to_many :semaphores` relation to model to use eager loading. Otherwise fetching semaphores for each vm separately at vm listing page causes N+1 query issue. Instead of all this mambo jambo, I might just update display_state as "deleting" at place where we increase destroy semaphore. This place is route file. Updating vm model at outside of its nexus felt like antipattern. I didn't do that. Fixes #438
8 lines
123 B
Ruby
8 lines
123 B
Ruby
# frozen_string_literal: true
|
|
|
|
Sequel.migration do
|
|
change do
|
|
add_enum_value(:vm_display_state, "deleting")
|
|
end
|
|
end
|