1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-06 14:05:20 +02:00

Merge pull request #1 from mwjdaws/codex/assess-and-correct-code-gaps-in-monolith

Fix investment analytics integration
This commit is contained in:
mwjdaws 2025-07-20 16:18:43 -04:00 committed by GitHub
commit ce39c86380
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 38 additions and 11 deletions

View file

@ -3,3 +3,7 @@ SELF_HOSTED=false
# Enable Synth market data (careful, this will use your API credits)
SYNTH_API_KEY=yourapikeyhere
# Enable the Investment Analytics app and configure FMP API access
ENABLE_INVESTMENT_ANALYTICS_APP=false
FMP_API_KEY=yourfmpapikeyhere

View file

@ -1,8 +1,8 @@
# app/apps/investment_analytics/services/investment_analytics/fmp_provider.rb
module InvestmentAnalytics
class FmpProvider
include Provider::Base
require Rails.root.join("app", "models", "provider")
class FmpProvider < ::Provider
BASE_URL = "https://financialmodelingprep.com/api/v3"

View file

@ -8,10 +8,17 @@ class Provider::Registry
validates :concept, inclusion: { in: CONCEPTS }
class << self
@@additional_providers = {}
def for_concept(concept)
new(concept.to_sym)
end
def register_provider(name, provider_class)
@@additional_providers[name.to_sym] = provider_class
define_singleton_method(name) { provider_class.new }
end
def get_provider(name)
send(name)
rescue NoMethodError
@ -98,7 +105,7 @@ class Provider::Registry
when :llm
%i[openai]
else
%i[synth plaid_us plaid_eu github openai]
%i[synth plaid_us plaid_eu github openai] + self.class.class_variable_get(:@@additional_providers).keys
end
end
end

View file

@ -2,6 +2,8 @@
# Ensure the InvestmentAnalytics module is loaded
require_relative '../../app/apps/investment_analytics/investment_analytics'
require Rails.root.join('app', 'models', 'provider')
require Rails.root.join('app', 'models', 'provider', 'registry')
# Ensure the FmpProvider class is loaded
require_relative '../../app/apps/investment_analytics/services/investment_analytics/fmp_provider'

View file

@ -262,14 +262,6 @@ Rails.application.routes.draw do
get "privacy", to: redirect("https://maybefinance.com/privacy")
get "terms", to: redirect("https://maybefinance.com/tos")
namespace :investment_analytics do
resources :dashboards, only: [:index] do
collection do
get :portfolio_summary
get :dividend_forecast
end
end
end
# Defines the root path route ("/")
root "pages#dashboard"

View file

@ -0,0 +1,22 @@
require "test_helper"
require "ostruct"
class InvestmentAnalytics::FmpProviderTest < ActiveSupport::TestCase
setup do
@provider = InvestmentAnalytics::FmpProvider.new(api_key: "test")
end
test "quote returns parsed data" do
response = OpenStruct.new(success?: true, body: [{ price: 10 }.to_json])
HTTParty.expects(:get).returns(response)
result = @provider.quote("AAPL")
assert_equal({"price" => 10}, result)
end
test "error responses raise provider error" do
response = OpenStruct.new(success?: false, code: 404, body: "not found")
assert_raises(Provider::Error) { @provider.send(:handle_response, response) }
end
end