mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-07 22:45:20 +02:00
- Add index to sync status
This commit is contained in:
parent
d05946596e
commit
097a769dc7
3 changed files with 11 additions and 3 deletions
|
@ -49,7 +49,7 @@ class PlaidItem < ApplicationRecord
|
|||
def syncing?
|
||||
Sync.joins("LEFT JOIN accounts a ON a.id = syncs.syncable_id AND syncs.syncable_type = 'Account'")
|
||||
.joins("LEFT JOIN plaid_accounts pa ON pa.id = a.plaid_account_id")
|
||||
.where("syncs.syncable_id = ? OR pa.plaid_item_id = ?", id, id)
|
||||
.where("syncs.syncable_id = ? OR pa.plaid_item_id = ?", SecureRandom.uuid, SecureRandom.uuid)
|
||||
.visible
|
||||
.exists?
|
||||
end
|
||||
|
|
7
db/migrate/20250605031616_add_index_to_sync_status.rb
Normal file
7
db/migrate/20250605031616_add_index_to_sync_status.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class AddIndexToSyncStatus < ActiveRecord::Migration[7.2]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_index :syncs, :status, if_not_exists: true, algorithm: :concurrently
|
||||
end
|
||||
end
|
5
db/schema.rb
generated
5
db/schema.rb
generated
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_05_23_131455) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_06_05_031616) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
|
@ -30,7 +30,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_05_23_131455) do
|
|||
t.decimal "balance", precision: 19, scale: 4
|
||||
t.string "currency"
|
||||
t.boolean "is_active", default: true, null: false
|
||||
t.virtual "classification", type: :string, as: "\nCASE\n WHEN ((accountable_type)::text = ANY ((ARRAY['Loan'::character varying, 'CreditCard'::character varying, 'OtherLiability'::character varying])::text[])) THEN 'liability'::text\n ELSE 'asset'::text\nEND", stored: true
|
||||
t.virtual "classification", type: :string, as: "\nCASE\n WHEN ((accountable_type)::text = ANY (ARRAY[('Loan'::character varying)::text, ('CreditCard'::character varying)::text, ('OtherLiability'::character varying)::text])) THEN 'liability'::text\n ELSE 'asset'::text\nEND", stored: true
|
||||
t.uuid "import_id"
|
||||
t.uuid "plaid_account_id"
|
||||
t.boolean "scheduled_for_deletion", default: false
|
||||
|
@ -593,6 +593,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_05_23_131455) do
|
|||
t.date "window_start_date"
|
||||
t.date "window_end_date"
|
||||
t.index ["parent_id"], name: "index_syncs_on_parent_id"
|
||||
t.index ["status"], name: "index_syncs_on_status"
|
||||
t.index ["syncable_type", "syncable_id"], name: "index_syncs_on_syncable"
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue