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 was merged in pull request #2110.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user