From 5c9ac560e7e916c8a082c99309fbd4031b1a6803 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 5 Oct 2016 00:10:23 +0800 Subject: Introduce all_state_names so that we could avoid NOT IN --- app/models/concerns/has_status.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/models/concerns') diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb index 2dd2c5f2c0f..9f64f76721d 100644 --- a/app/models/concerns/has_status.rb +++ b/app/models/concerns/has_status.rb @@ -43,6 +43,10 @@ module HasStatus def finished_at all.maximum(:finished_at) end + + def all_state_names + state_machines.values.flat_map(&:states).flat_map { |s| s.map(&:name) } + end end included do -- cgit v1.2.3