mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 07:39:39 +02:00
Account:: namespace simplifications and cleanup (#2110)
* Flatten Holding model * Flatten balance model * Entries domain renames * Fix valuations reference * Fix trades stream * Fix brakeman warnings * Fix tests * Replace existing entryable type references in DB
This commit is contained in:
parent
f181ba941f
commit
e657c40d19
172 changed files with 1297 additions and 1258 deletions
|
@ -81,8 +81,8 @@ namespace :securities do
|
|||
puts " Duplicate without MIC: #{security.id}"
|
||||
|
||||
# Count affected records
|
||||
holdings_count = Account::Holding.where(security_id: security.id).count
|
||||
trades_count = Account::Trade.where(security_id: security.id).count
|
||||
holdings_count = Holding.where(security_id: security.id).count
|
||||
trades_count = Trade.where(security_id: security.id).count
|
||||
prices_count = Security::Price.where(security_id: security.id).count
|
||||
|
||||
puts " Would update:"
|
||||
|
@ -94,8 +94,8 @@ namespace :securities do
|
|||
begin
|
||||
ActiveRecord::Base.transaction do
|
||||
# Update all references to point to the canonical security
|
||||
Account::Holding.where(security_id: security.id).update_all(security_id: canonical.id)
|
||||
Account::Trade.where(security_id: security.id).update_all(security_id: canonical.id)
|
||||
Holding.where(security_id: security.id).update_all(security_id: canonical.id)
|
||||
Trade.where(security_id: security.id).update_all(security_id: canonical.id)
|
||||
Security::Price.where(security_id: security.id).update_all(security_id: canonical.id)
|
||||
|
||||
# Delete the duplicate
|
||||
|
@ -134,8 +134,8 @@ namespace :securities do
|
|||
puts " Duplicates: #{duplicates.map(&:id).join(', ')}"
|
||||
|
||||
# Count affected records
|
||||
holdings_count = Account::Holding.where(security_id: duplicates).count
|
||||
trades_count = Account::Trade.where(security_id: duplicates).count
|
||||
holdings_count = Holding.where(security_id: duplicates).count
|
||||
trades_count = Trade.where(security_id: duplicates).count
|
||||
prices_count = Security::Price.where(security_id: duplicates).count
|
||||
|
||||
total_holdings += holdings_count
|
||||
|
@ -151,8 +151,8 @@ namespace :securities do
|
|||
begin
|
||||
ActiveRecord::Base.transaction do
|
||||
# Update all references to point to the canonical security
|
||||
Account::Holding.where(security_id: duplicates).update_all(security_id: canonical.id)
|
||||
Account::Trade.where(security_id: duplicates).update_all(security_id: canonical.id)
|
||||
Holding.where(security_id: duplicates).update_all(security_id: canonical.id)
|
||||
Trade.where(security_id: duplicates).update_all(security_id: canonical.id)
|
||||
Security::Price.where(security_id: duplicates).update_all(security_id: canonical.id)
|
||||
|
||||
# Delete the duplicates
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue