mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 05:09:38 +02:00
Data provider simplification, tests, and documentation (#1997)
* Ignore env.test from source control * Simplification of providers interface * Synth tests * Update money to use new find rates method * Remove unused issues code * Additional issue feature removals * Update price data fetching and tests * Update documentation for providers * Security test fixes * Fix self host test * Update synth usage data access * Remove AI pr schema changes
This commit is contained in:
parent
dd75cadebc
commit
f65b93a352
95 changed files with 2014 additions and 1638 deletions
|
@ -0,0 +1,5 @@
|
|||
class RemoveTickerFromSecurityPrices < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
remove_column :security_prices, :ticker
|
||||
end
|
||||
end
|
11
db/migrate/20250316103753_remove_issues.rb
Normal file
11
db/migrate/20250316103753_remove_issues.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class RemoveIssues < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
drop_table :issues do |t|
|
||||
t.references :issuable, polymorphic: true, null: false
|
||||
t.string :type, null: false
|
||||
t.integer :severity, null: false
|
||||
t.datetime :last_observed_at
|
||||
t.datetime :resolved_at
|
||||
end
|
||||
end
|
||||
end
|
31
db/migrate/20250316122019_security_price_unique_index.rb
Normal file
31
db/migrate/20250316122019_security_price_unique_index.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
class SecurityPriceUniqueIndex < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
# First, we have to delete duplicate prices from DB so we can apply the unique index
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
execute <<~SQL
|
||||
DELETE FROM security_prices
|
||||
WHERE id IN (
|
||||
SELECT id FROM (
|
||||
SELECT id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY security_id, date, currency
|
||||
ORDER BY updated_at DESC, id DESC
|
||||
) as row_num
|
||||
FROM security_prices
|
||||
) as duplicates
|
||||
WHERE row_num > 1
|
||||
);
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
||||
add_index :security_prices, [ :security_id, :date, :currency ], unique: true
|
||||
change_column_null :security_prices, :date, false
|
||||
change_column_null :security_prices, :price, false
|
||||
change_column_null :security_prices, :currency, false
|
||||
|
||||
change_column_null :exchange_rates, :date, false
|
||||
change_column_null :exchange_rates, :rate, false
|
||||
end
|
||||
end
|
27
db/schema.rb
generated
27
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_03_04_140435) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_03_16_122019) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
|
@ -219,8 +219,8 @@ ActiveRecord::Schema[7.2].define(version: 2025_03_04_140435) do
|
|||
create_table "exchange_rates", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.string "from_currency", null: false
|
||||
t.string "to_currency", null: false
|
||||
t.decimal "rate"
|
||||
t.date "date"
|
||||
t.decimal "rate", null: false
|
||||
t.date "date", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["from_currency", "to_currency", "date"], name: "index_exchange_rates_on_base_converted_date_unique", unique: true
|
||||
|
@ -449,19 +449,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_03_04_140435) do
|
|||
t.index ["token"], name: "index_invite_codes_on_token", unique: true
|
||||
end
|
||||
|
||||
create_table "issues", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.string "issuable_type"
|
||||
t.uuid "issuable_id"
|
||||
t.string "type"
|
||||
t.integer "severity"
|
||||
t.datetime "last_observed_at"
|
||||
t.datetime "resolved_at"
|
||||
t.jsonb "data"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["issuable_type", "issuable_id"], name: "index_issues_on_issuable"
|
||||
end
|
||||
|
||||
create_table "loans", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
|
@ -560,13 +547,13 @@ ActiveRecord::Schema[7.2].define(version: 2025_03_04_140435) do
|
|||
end
|
||||
|
||||
create_table "security_prices", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.string "ticker"
|
||||
t.date "date"
|
||||
t.decimal "price", precision: 19, scale: 4
|
||||
t.string "currency", default: "USD"
|
||||
t.date "date", null: false
|
||||
t.decimal "price", precision: 19, scale: 4, null: false
|
||||
t.string "currency", default: "USD", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.uuid "security_id"
|
||||
t.index ["security_id", "date", "currency"], name: "index_security_prices_on_security_id_and_date_and_currency", unique: true
|
||||
t.index ["security_id"], name: "index_security_prices_on_security_id"
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue