stateful_models 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 140dacad43c4287b2317ab10567b808c4c6c751715a640d04560ea9396f15b11
4
- data.tar.gz: b0590f0190d823fad1693ebec1a65e933d465693ac0ecb2688f045fab2f84474
3
+ metadata.gz: 8eb127e7632f183232f299936b44df5fc17f3208decb1da2863c802e8f4f2b69
4
+ data.tar.gz: bb6062a0184b16afa0a933f8e9c35fd9ca90ad1e8129b6de95ce6d1c1433ffb2
5
5
  SHA512:
6
- metadata.gz: c0e603d13345f3c36c68dcea633b2d0d37d1de41d5de961b63f81970b572e90e76a2b2f642c2868a94f1b440400f795d4243490159ed58265ab45770a27cb5d2
7
- data.tar.gz: dc8688d4ebc992dc7cf32a92dc17d1bda1c2de58ea6747292fd746b529b3a5fdccbe9295090854b252b6b42689fed613b30821655d2a8deb4462b4daabaa13d5
6
+ metadata.gz: b254a3c531422e64ec011fae308ab9999b812f1b85fea61bceb159656091ac9d9fab2723b5b0e8e0802944a1c92d29d3c94822e89f5cbc772cbf06218487f903
7
+ data.tar.gz: d27742123bce580f7813de17adcee9c5485d5bfc60e2a628fa8f068ce3a6874af8a0e372127b89b86454263738a8563c22e2fb8455fa2c3dda75ef6a6b5d33df
data/CHANGELOG.md CHANGED
@@ -13,7 +13,18 @@
13
13
  - Updated `add_state` method to support custom state classes
14
14
  - Improved test coverage for inheritance and custom state types
15
15
 
16
- ## [0.1.0] - 2024-12-21
16
+ ## [0.0.3] - 2024-01-14
17
+
18
+ - Adding current_state method
19
+ - Adding DB indexes for state lookups
20
+ - Adding query methods for state types on stateable (`stateable.state_type` and `stateable.state_types`)
21
+
22
+ ## [0.0.2] - 2024-12-23
23
+
24
+ - Added test coverage
25
+ - Refactor of State model into a inheritable Base class
26
+
27
+ ## [0.0.1] - 2024-12-21
17
28
 
18
29
  - Initial release
19
30
  - See READme.md
@@ -6,20 +6,38 @@ module HasStates
6
6
  class InstallGenerator < Rails::Generators::Base
7
7
  source_root File.expand_path('templates', __dir__)
8
8
 
9
+ TEMPLATES = [
10
+ {
11
+ source: 'create_has_states_states.rb.erb',
12
+ destination: "db/migrate/%s_create_has_states_states.rb"
13
+ },
14
+ {
15
+ source: 'create_indexes_on_has_states_states.rb.erb',
16
+ destination: "db/migrate/%s_create_indexes_on_has_states_states.rb"
17
+ },
18
+ {
19
+ source: 'initializer.rb.erb',
20
+ destination: "config/initializers/has_states.rb"
21
+ }
22
+ ].freeze
23
+
9
24
  def install
10
25
  puts 'Installing HasStates...'
11
26
 
12
- template(
13
- 'create_has_states_states.rb.erb',
14
- "db/migrate/#{Time.now.utc.strftime('%Y%m%d%H%M%S')}_create_has_states_states.rb"
15
- )
16
-
17
- template(
18
- 'initializer.rb.erb',
19
- 'config/initializers/has_states.rb'
20
- )
27
+ TEMPLATES.each do |template|
28
+ make_template(**template)
29
+ end
21
30
 
22
31
  puts 'HasStates installed successfully!'
23
32
  end
33
+
34
+ private
35
+
36
+ def make_template(source:, destination:)
37
+ timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S')
38
+ destination = destination % timestamp if destination.include?('%s')
39
+
40
+ template(source, destination)
41
+ end
24
42
  end
25
43
  end
@@ -1,4 +1,4 @@
1
- class CreateHasStatesStates < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
1
+ class CreateHasStatesStates < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
2
  def change
3
3
  create_table :has_states_states do |t|
4
4
  t.string :type, null: false
@@ -0,0 +1,11 @@
1
+ class CreateIndexesOnHasStatesStates < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
2
+ def change
3
+ change_table :has_states_states do |t|
4
+ t.index %i[stateable_id state_type]
5
+ t.index %i[stateable_id state_type status]
6
+ t.index %i[stateable_id state_type created_at]
7
+ t.index %i[stateable_id state_type status created_at]
8
+ t.index %i[stateable_type stateable_id]
9
+ end
10
+ end
11
+ end
@@ -17,8 +17,12 @@ module HasStates
17
17
 
18
18
  @state_types[name.to_s] = type
19
19
 
20
+ # HasStates::State model method generators
20
21
  generate_state_type_scope(name)
21
22
  generate_status_predicates(type.statuses)
23
+
24
+ # Included model method generators
25
+ generate_state_type_queries(name)
22
26
  generate_state_type_status_predicates(name, type.statuses)
23
27
  end
24
28
 
@@ -36,6 +40,18 @@ module HasStates
36
40
  end
37
41
  end
38
42
 
43
+ def generate_state_type_queries(state_type)
44
+ # Singular for finding the most recent state of a given type and status
45
+ @model_class.define_method(:"#{state_type}") do
46
+ states.where(state_type: state_type).order(created_at: :desc).first
47
+ end
48
+
49
+ # Plural for finding all states of a given type and status
50
+ @model_class.define_method(:"#{ActiveSupport::Inflector.pluralize(state_type)}") do
51
+ states.where(state_type: state_type).order(created_at: :desc)
52
+ end
53
+ end
54
+
39
55
  def generate_state_type_status_predicates(state_type, statuses)
40
56
  statuses.each do |status_name|
41
57
  @model_class.define_method(:"#{state_type}_#{status_name}?") do
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HasStates
4
- class State < Base
5
- end
4
+ class State < Base; end
6
5
  end
@@ -6,18 +6,21 @@ module HasStates
6
6
 
7
7
  included do
8
8
  has_many :states, class_name: 'HasStates::Base',
9
- as: :stateable,
10
- dependent: :destroy
9
+ as: :stateable,
10
+ dependent: :destroy
11
11
  end
12
12
 
13
13
  # Instance methods for managing states
14
14
  def add_state(type, status: 'pending', metadata: {}, state_class: HasStates::State)
15
- states.create!(
16
- type: state_class.name,
17
- state_type: type,
18
- status: status,
19
- metadata: metadata
20
- )
15
+ states.create!(type: state_class.name, state_type: type, status: status, metadata: metadata)
16
+ end
17
+
18
+ def current_state(type)
19
+ states.where(state_type: type).order(created_at: :desc).first
20
+ end
21
+
22
+ def current_states(type)
23
+ states.where(state_type: type).order(created_at: :desc)
21
24
  end
22
25
  end
23
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HasStates
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- stateful_models (0.0.1)
4
+ stateful_models (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,42 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- HasStates.configure do |config|
4
- # Configure your models and their state types below
5
- #
6
- # Example configuration:
7
- #
8
- # config.configure_model User do |model|
9
- # # KYC state type with its allowed statuses
10
- # model.state_type :kyc do |type|
11
- # type.statuses = [
12
- # 'pending', # Initial state
13
- # 'documents_required', # Waiting for user documents
14
- # 'under_review', # Documents being reviewed
15
- # 'approved', # KYC process completed successfully
16
- # 'rejected' # KYC process failed
17
- # ]
18
- # end
19
- #
20
- # # Onboarding state type with different statuses
21
- # model.state_type :onboarding do |type|
22
- # type.statuses = [
23
- # 'pending', # Just started
24
- # 'email_verified', # Email verification complete
25
- # 'profile_complete', # User filled all required fields
26
- # 'completed' # Onboarding finished
27
- # ]
28
- # end
29
- # end
30
- #
31
- # config.configure_model Company do |model|
32
- # model.state_type :verification do |type|
33
- # type.statuses = [
34
- # 'pending',
35
- # 'documents_submitted',
36
- # 'under_review',
37
- # 'verified',
38
- # 'rejected'
39
- # ]
40
- # end
41
- # end
3
+ # Configure after the application is initialized
4
+ Rails.application.config.after_initialize do
5
+ HasStates.configure do |config|
6
+ # Configure your models and their state types below
7
+ #
8
+ # Example configuration:
9
+ #
10
+ config.configure_model User do |model|
11
+ # KYC state type with its allowed statuses
12
+ model.state_type :kyc do |type|
13
+ type.statuses = [
14
+ 'pending', # Initial state
15
+ 'documents_required', # Waiting for user documents
16
+ 'under_review', # Documents being reviewed
17
+ 'approved', # KYC process completed successfully
18
+ 'rejected' # KYC process failed
19
+ ]
20
+ end
21
+
22
+ # Onboarding state type with different statuses
23
+ model.state_type :onboarding do |type|
24
+ type.statuses = [
25
+ 'pending', # Just started
26
+ 'email_verified', # Email verification complete
27
+ 'profile_complete', # User filled all required fields
28
+ 'completed' # Onboarding finished
29
+ ]
30
+ end
31
+ end
32
+ #
33
+ # config.configure_model Company do |model|
34
+ # model.state_type :verification do |type|
35
+ # type.statuses = [
36
+ # 'pending',
37
+ # 'documents_submitted',
38
+ # 'under_review',
39
+ # 'verified',
40
+ # 'rejected'
41
+ # ]
42
+ # end
43
+ # end
44
+ end
42
45
  end
@@ -0,0 +1,10 @@
1
+ class CreateIndexesOnHasStatesStates < ActiveRecord::Migration[8.0]
2
+ def change
3
+ change_table :has_states_states do |t|
4
+ t.index %i[stateable_id state_type]
5
+ t.index %i[stateable_id state_type status]
6
+ t.index %i[stateable_id state_type created_at]
7
+ t.index %i[stateable_id state_type status created_at]
8
+ end
9
+ end
10
+ end
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema[8.0].define(version: 2024_12_23_212128) do
13
+ ActiveRecord::Schema[8.0].define(version: 2025_01_14_175939) do
14
14
  create_table "companies", force: :cascade do |t|
15
15
  t.string "name"
16
16
  t.datetime "created_at", null: false
@@ -27,6 +27,10 @@ ActiveRecord::Schema[8.0].define(version: 2024_12_23_212128) do
27
27
  t.datetime "completed_at"
28
28
  t.datetime "created_at", null: false
29
29
  t.datetime "updated_at", null: false
30
+ t.index ["stateable_id", "state_type", "created_at"], name: "idx_on_stateable_id_state_type_created_at_b5d09fb6ee"
31
+ t.index ["stateable_id", "state_type", "status", "created_at"], name: "idx_on_stateable_id_state_type_status_created_at_19e1cf37c2"
32
+ t.index ["stateable_id", "state_type", "status"], name: "idx_on_stateable_id_state_type_status_6d3d026e4d"
33
+ t.index ["stateable_id", "state_type"], name: "index_has_states_states_on_stateable_id_and_state_type"
30
34
  t.index ["stateable_type", "stateable_id"], name: "index_has_states_states_on_stateable"
31
35
  t.index ["stateable_type", "stateable_id"], name: "index_has_states_states_on_stateable_type_and_stateable_id"
32
36
  t.index ["type", "stateable_id"], name: "index_has_states_states_on_type_and_stateable_id"
@@ -257,3 +257,89 @@ Migrating to CreateHasStatesStates (20241223212128)
257
257
  TRANSACTION (0.1ms) BEGIN immediate TRANSACTION /*application='Dummy'*/
258
258
  KYCState Create (0.6ms) INSERT INTO "has_states_states" ("type", "state_type", "status", "metadata", "stateable_type", "stateable_id", "completed_at", "created_at", "updated_at") VALUES ('KYCState', 'kyc', 'pending', '{"document_type":"passport"}', 'User', 1, NULL, '2024-12-23 21:38:20.849253', '2024-12-23 21:38:20.849253') RETURNING "id" /*application='Dummy'*/
259
259
  TRANSACTION (14.6ms) COMMIT TRANSACTION /*application='Dummy'*/
260
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
261
+ User Load (0.3ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
262
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
263
+ HasStates::Base Load (0.2ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' ORDER BY "has_states_states"."created_at" DESC LIMIT 1 /*application='Dummy'*/
264
+ HasStates::Base Load (0.4ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' /* loading for pp */ ORDER BY "has_states_states"."created_at" DESC LIMIT 11 /*application='Dummy'*/
265
+ HasStates::Base Load (0.1ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/
266
+ HasStates::State Load (0.3ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."type" = 'HasStates::State' /* loading for pp */ LIMIT 11 /*application='Dummy'*/
267
+ HasStates::Base Exists? (0.2ms) SELECT 1 AS one FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'onboarding' AND "has_states_states"."status" = 'pending' LIMIT 1 /*application='Dummy'*/
268
+ HasStates::Base Exists? (0.3ms) SELECT 1 AS one FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'onboarding' AND "has_states_states"."status" = 'email_verified' LIMIT 1 /*application='Dummy'*/
269
+ HasStates::Base Load (0.3ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for pp */ LIMIT 11 /*application='Dummy'*/
270
+ HasStates::Base Load (0.1ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/
271
+ HasStates::State Pluck (0.2ms) SELECT "has_states_states"."type" FROM "has_states_states" WHERE "has_states_states"."type" = 'HasStates::State' /*application='Dummy'*/
272
+ HasStates::State Load (0.3ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."type" = 'HasStates::State' /*application='Dummy'*/
273
+ HasStates::Base Load (0.3ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for pp */ LIMIT 11 /*application='Dummy'*/
274
+ HasStates::Base Load (0.2ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/
275
+ HasStates::State Update All (0.2ms) UPDATE "has_states_states" SET "type" = 'HasStates::State' WHERE "has_states_states"."type" = 'HasStates::State' AND "has_states_states"."type" = 'TestState' /*application='Dummy'*/
276
+ HasStates::Base Load (0.2ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for pp */ LIMIT 11 /*application='Dummy'*/
277
+ HasStates::Base Load (0.2ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/
278
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
279
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
280
+ HasStates::Base Load (0.1ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for pp */ LIMIT 11 /*application='Dummy'*/
281
+ HasStates::Base Load (0.2ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/
282
+ User Load (0.3ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
283
+ HasStates::Base Load (0.3ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' ORDER BY "has_states_states"."created_at" DESC LIMIT 1 /*application='Dummy'*/
284
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
285
+ HasStates::Base Load (0.1ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for pp */ LIMIT 11 /*application='Dummy'*/
286
+ HasStates::Base Load (0.1ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/
287
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
288
+ HasStates::Base Load (0.2ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' ORDER BY "has_states_states"."created_at" DESC LIMIT 1 /*application='Dummy'*/
289
+ HasStates::State Update All (13.4ms) UPDATE "has_states_states" SET "type" = 'HasStates::State' WHERE "has_states_states"."type" = 'HasStates::State' /*application='Dummy'*/
290
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
291
+ HasStates::Base Load (0.1ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for pp */ LIMIT 11 /*application='Dummy'*/
292
+ HasStates::Base Load (0.1ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/
293
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
294
+ HasStates::Base Load (0.2ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' ORDER BY "has_states_states"."created_at" DESC LIMIT 1 /*application='Dummy'*/
295
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
296
+ HasStates::Base Load (0.2ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' /* loading for pp */ ORDER BY "has_states_states"."created_at" DESC LIMIT 11 /*application='Dummy'*/
297
+ HasStates::Base Load (0.1ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' /* loading for inspect */ LIMIT 11 /*application='Dummy'*/
298
+  (0.2ms) SELECT id, type, state_type, status FROM has_states_states /*application='Dummy'*/
299
+ HasStates::Base Update All (0.5ms) UPDATE "has_states_states" SET "type" = 'HasStates::State' WHERE "has_states_states"."type" IN ('TestState', 'KYCState') /*application='Dummy'*/
300
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
301
+ HasStates::Base Load (0.2ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' /* loading for pp */ ORDER BY "has_states_states"."created_at" DESC LIMIT 11 /*application='Dummy'*/
302
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
303
+ HasStates::Base Load (0.3ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' ORDER BY "has_states_states"."created_at" DESC LIMIT 1 /*application='Dummy'*/
304
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
305
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
306
+ HasStates::Base Load (0.2ms) SELECT "has_states_states".* FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' ORDER BY "has_states_states"."created_at" DESC LIMIT 1 /*application='Dummy'*/
307
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
308
+ HasStates::Base Exists? (0.1ms) SELECT 1 AS one FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' AND "has_states_states"."status" = 'approved' LIMIT 1 /*application='Dummy'*/
309
+ User Load (0.2ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
310
+ User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1 /*application='Dummy'*/
311
+ HasStates::Base Exists? (0.1ms) SELECT 1 AS one FROM "has_states_states" WHERE "has_states_states"."stateable_id" = 1 AND "has_states_states"."stateable_type" = 'User' AND "has_states_states"."state_type" = 'kyc' AND "has_states_states"."status" = 'approved' LIMIT 1 /*application='Dummy'*/
312
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT * FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = 'environment' ORDER BY "ar_internal_metadata"."key" ASC LIMIT 1 /*application='Dummy'*/
313
+ ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC /*application='Dummy'*/
314
+ Migrating to CreateIndexesOnHasStatesStates (20250114175939)
315
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT * FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = 'environment' ORDER BY "ar_internal_metadata"."key" ASC LIMIT 1 /*application='Dummy'*/
316
+ ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC /*application='Dummy'*/
317
+ Migrating to CreateIndexesOnHasStatesStates (20250114175939)
318
+ TRANSACTION (0.0ms) BEGIN immediate TRANSACTION /*application='Dummy'*/
319
+  (0.6ms) CREATE INDEX "index_has_states_states_on_stateable_id_and_state_type" ON "has_states_states" ("stateable_id", "state_type") /*application='Dummy'*/
320
+  (0.1ms) CREATE INDEX "idx_on_stateable_id_state_type_status_6d3d026e4d" ON "has_states_states" ("stateable_id", "state_type", "status") /*application='Dummy'*/
321
+  (0.0ms) CREATE INDEX "idx_on_stateable_id_state_type_created_at_b5d09fb6ee" ON "has_states_states" ("stateable_id", "state_type", "created_at") /*application='Dummy'*/
322
+  (0.0ms) CREATE INDEX "idx_on_stateable_id_state_type_status_created_at_19e1cf37c2" ON "has_states_states" ("stateable_id", "state_type", "status", "created_at") /*application='Dummy'*/
323
+  (0.1ms) CREATE INDEX "index_has_states_states_on_stateble_type_and_stateable_id" ON "has_states_states" ("stateble_type", "stateable_id") /*application='Dummy'*/
324
+ TRANSACTION (0.0ms) ROLLBACK TRANSACTION /*application='Dummy'*/
325
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT * FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = 'environment' ORDER BY "ar_internal_metadata"."key" ASC LIMIT 1 /*application='Dummy'*/
326
+ ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC /*application='Dummy'*/
327
+ Migrating to CreateIndexesOnHasStatesStates (20250114175939)
328
+ TRANSACTION (0.0ms) BEGIN immediate TRANSACTION /*application='Dummy'*/
329
+  (0.7ms) CREATE INDEX "index_has_states_states_on_stateable_id_and_state_type" ON "has_states_states" ("stateable_id", "state_type") /*application='Dummy'*/
330
+  (0.1ms) CREATE INDEX "idx_on_stateable_id_state_type_status_6d3d026e4d" ON "has_states_states" ("stateable_id", "state_type", "status") /*application='Dummy'*/
331
+  (0.0ms) CREATE INDEX "idx_on_stateable_id_state_type_created_at_b5d09fb6ee" ON "has_states_states" ("stateable_id", "state_type", "created_at") /*application='Dummy'*/
332
+  (0.0ms) CREATE INDEX "idx_on_stateable_id_state_type_status_created_at_19e1cf37c2" ON "has_states_states" ("stateable_id", "state_type", "status", "created_at") /*application='Dummy'*/
333
+  (0.1ms) CREATE INDEX "index_has_states_states_on_stateable_type_and_stateable_id" ON "has_states_states" ("stateable_type", "stateable_id") /*application='Dummy'*/
334
+ TRANSACTION (0.0ms) ROLLBACK TRANSACTION /*application='Dummy'*/
335
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT * FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = 'environment' ORDER BY "ar_internal_metadata"."key" ASC LIMIT 1 /*application='Dummy'*/
336
+ ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC /*application='Dummy'*/
337
+ Migrating to CreateIndexesOnHasStatesStates (20250114175939)
338
+ TRANSACTION (0.0ms) BEGIN immediate TRANSACTION /*application='Dummy'*/
339
+  (0.7ms) CREATE INDEX "index_has_states_states_on_stateable_id_and_state_type" ON "has_states_states" ("stateable_id", "state_type") /*application='Dummy'*/
340
+  (0.1ms) CREATE INDEX "idx_on_stateable_id_state_type_status_6d3d026e4d" ON "has_states_states" ("stateable_id", "state_type", "status") /*application='Dummy'*/
341
+  (0.0ms) CREATE INDEX "idx_on_stateable_id_state_type_created_at_b5d09fb6ee" ON "has_states_states" ("stateable_id", "state_type", "created_at") /*application='Dummy'*/
342
+  (0.0ms) CREATE INDEX "idx_on_stateable_id_state_type_status_created_at_19e1cf37c2" ON "has_states_states" ("stateable_id", "state_type", "status", "created_at") /*application='Dummy'*/
343
+ ActiveRecord::SchemaMigration Create (0.0ms) INSERT INTO "schema_migrations" ("version") VALUES ('20250114175939') RETURNING "version" /*application='Dummy'*/
344
+ TRANSACTION (14.2ms) COMMIT TRANSACTION /*application='Dummy'*/
345
+ ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC /*application='Dummy'*/